Skip to content

Instantly share code, notes, and snippets.

@jbadger3
Created September 9, 2022 18:07
Show Gist options
  • Save jbadger3/df46c114b83b7706decee7a5ec9aa80b to your computer and use it in GitHub Desktop.
Save jbadger3/df46c114b83b7706decee7a5ec9aa80b to your computer and use it in GitHub Desktop.
on_command_line_applications_in_swift
import Terminus
let terminal = Terminal.shared
let lineEditor = LineEditor()
lineEditor.bufferHandler = {
var shouldWriteBuffer = false
if let greenRange = lineEditor.buffer.range(of: "green") {
lineEditor.buffer[greenRange].terminalTextAttributes = [.color(Color(r: 0, g: 255, b: 0))]
shouldWriteBuffer = true
}
if let yellowRange = lineEditor.buffer.range(of: "yellow") {
lineEditor.buffer[yellowRange].terminalTextAttributes = [.color(Color(r: 255, g: 255, b: 0))]
shouldWriteBuffer = true
}
if let redRange = lineEditor.buffer.range(of: "red") {
lineEditor.buffer[redRange].terminalTextAttributes = [.color(Color(r: 255, g: 0, b: 0))]
shouldWriteBuffer = true
}
return shouldWriteBuffer
}
let input = lineEditor.getInput()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment