Low-level terminal primitives for MoonBit native and wasm targets: a sidecar-held controlling terminal with raw mode, size and resize events, VT command output, and host input decoding.
import {
"moonbit-community/tty"
"moonbit-community/tty/color" @tty/color
"moonbit-community/tty/input" @tty/input
}async fn main {
let tty = @tty.Tty::stdio()
tty.hide_cursor()
tty.set_cursor_position(1, 1)
tty.set_bold()
tty.set_foreground(Basic(Green))
tty.write("hello from tty\r\n")
tty.reset_style()
tty.show_cursor()
}async fn main {
let tty = @tty.Tty::open()
defer tty.close()
tty.with_raw_mode(() => {
tty.write("press q to quit\r\n")
while true {
match tty.read_event() {
Input(Key(key)) =>
match key.code {
Char('q') => break
_ => ()
}
Input(Paste(_)) => ()
Input(Mouse(_)) => ()
Input(FocusIn) => ()
Input(FocusOut) => ()
Input(Unknown(_)) => ()
Resize(_) => ()
}
}
})
}moon run examples/raw
moon run examples/input
moon run examples/color
moon run examples/cursor
moon run examples/pager -- README.md
moon run examples/agentmoon run examples/raw --target wasm
moon run examples/input --target wasm
moon run examples/pager --target wasm -- README.mdmoon fmt
moon test .
moon test
moon check
moon infopub(open) trait Fd {
fn fd(Self) -> Int raise
}pub(all) enum Command {
Print(StringView)
SetClipboard(StringView)
EnterAltScreen
LeaveAltScreen
BeginSynchronizedUpdate
EndSynchronizedUpdate
EnableBracketedPaste
DisableBracketedPaste
EnableFocusTracking
DisableFocusTracking
EnableAutoWrap
DisableAutoWrap
PushKeyboardEnhancementFlags(KeyboardEnhancementFlags)
PopKeyboardEnhancementFlags
HideCursor
ShowCursor
SaveCursor
RestoreCursor
CursorUp(Int)
CursorDown(Int)
CursorForward(Int)
CursorBack(Int)
CursorNextLine(Int)
CursorPrevLine(Int)
CursorHorizontalAbsolute(Int)
CursorPosition(Int, Int)
EraseLineAll
EraseLineLeft
EraseLineRight
EraseDisplay
EraseScrollback
SetTopBottomMargins(Int, Int)
ResetTopBottomMargins
ReverseIndex
SetForeground(Color)
SetBackground(Color)
ResetForeground
ResetBackground
SetBold
ResetBold
SetItalic
ResetItalic
SetUnderline
ResetUnderline
SetReverse
ResetReverse
ResetStyle
} derive(Eq, Debug)fn KeyboardEnhancementFlags::new(disambiguate_escape_codes? : Bool, report_event_types? : Bool, report_alternate_keys? : Bool, report_all_keys_as_escape_codes? : Bool, report_associated_text? : Bool) -> KeyboardEnhancementFlagsfn KeyboardEnhancementFlags::not_equal(x : KeyboardEnhancementFlags, y : KeyboardEnhancementFlags) -> Boolfn KeyboardEnhancementFlags::report_all_keys_as_escape_codes(self : KeyboardEnhancementFlags) -> Booltype Statetype Ttyasync fn[T] Tty::with_keyboard_enhancements(self : Tty, flags : KeyboardEnhancementFlags, f : async () -> T) -> TInstall
Download zipLow-level terminal primitives for MoonBit native and wasm targets: a sidecar-held controlling terminal with raw mode, size and resize events, VT command output, and host input decoding.