Created
September 9, 2022 18:07
-
-
Save jbadger3/df46c114b83b7706decee7a5ec9aa80b to your computer and use it in GitHub Desktop.
on_command_line_applications_in_swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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