A pretty prompt library for Moonbit, providing an easy way to create interactive command-line interfaces with customizable prompts and input handling.
Dependencies
moon add sennenki/pretty_prompt
moon add sennenki/pretty_prompt/systemimport {
"sennenki/pretty_prompt" @pp,
"sennenki/pretty_prompt/system" @sys,
}///|
async fn main {
let prompt = @pp.Prompt::new(
@sys.SystemConsolePort::new(),
@sys.SystemClipboardPort::new(),
)
let result = prompt.read_line()
if result.is_success {
println("you typed: \{result.text}")
}
prompt.dispose()
}///|
async fn main {
let prompt = @pp.Prompt::new(
@sys.SystemConsolePort::new(),
@sys.SystemClipboardPort::new(),
)
let title = @pp.FormattedString::new(">>> ")
let result = prompt.read_line_with_prompt(title)
if result.is_success {
println(result.text)
}
prompt.dispose()
}///|
fn make_configuration() -> @pp.PromptConfiguration {
@pp.PromptConfiguration::new(
prompt=@pp.FormattedString::new("moon> "),
history=@pp.HistoryConfiguration::new(
persistent_history_filepath=".pretty_prompt_history",
max_entries=1000,
),
use_colors=true,
max_completion_items_count=8,
)
}///|
fn make_key_bindings() -> @pp.KeyBindings {
@pp.KeyBindings::new(
new_line=@pp.KeyPressPatterns::single(
@pp.KeyPressPattern::new(@console.Enter, shift=true),
),
)
}///|
fn make_callbacks() -> @pp.PromptCallbacks {
@pp.PromptCallbacks::new(
completion_items_provider=_ => [
@pp.CompletionItem::new("print"),
@pp.CompletionItem::new("println"),
],
should_open_completion_window=_ => false,
should_insert_soft_newline=(snapshot, _) => !snapshot.text.trim().is_empty(),
)
}///|
let history = @pp.HistoryConfiguration::new(
persistent_history_filepath=".pretty_prompt_history",
max_entries=500,
)fn render_diff(console : &ConsolePort, new_screen : Screen, old_screen : Screen, base_row : Int, base_col : Int) -> UnitInstall
Download zipA pretty prompt library for Moonbit, providing an easy way to create interactive command-line interfaces with customizable prompts and input handling.
Dependencies