ui crate, editor
This commit is contained in:
@@ -24,7 +24,7 @@ mod ui;
|
||||
mod utils;
|
||||
|
||||
use crate::animation::{AnimWidget, AnimationLayer};
|
||||
use crate::editor::{EditorState, draw_editor, handle_dialog_input};
|
||||
use crate::editor::{EditorState, draw_editor, handle_code_editor_input, handle_dialog_input};
|
||||
use crate::input::{
|
||||
InputMode, current_input_mode, handle_board_input, handle_editor_input, handle_menu_input,
|
||||
handle_scroll_input,
|
||||
@@ -40,7 +40,8 @@ use kiln_core::log::LogLine;
|
||||
use kiln_core::world;
|
||||
use ratatui::Frame;
|
||||
use ratatui::crossterm::event::{
|
||||
self, DisableMouseCapture, EnableMouseCapture, Event, KeyEventKind,
|
||||
self, DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, EnableMouseCapture,
|
||||
Event, KeyEventKind,
|
||||
};
|
||||
use ratatui::crossterm::execute;
|
||||
use ratatui::layout::{Constraint, Layout, Rect, Spacing};
|
||||
@@ -77,6 +78,9 @@ fn main() -> ExitCode {
|
||||
// resized by dragging its divider. Disabled again before restoring.
|
||||
let _ = execute!(io::stdout(), EnableMouseCapture);
|
||||
|
||||
// Enable bracketed paste so the code editor receives terminal pastes as one event.
|
||||
let _ = execute!(io::stdout(), EnableBracketedPaste);
|
||||
|
||||
// Detect terminal capabilities (now that we're in raw mode) and enable the
|
||||
// Kitty keyboard protocol when it's available, so scripts can rely on the
|
||||
// richer bindings it provides. Disabled again before restoring the terminal.
|
||||
@@ -105,6 +109,7 @@ fn main() -> ExitCode {
|
||||
if caps.keyboard_enhancement {
|
||||
let _ = term::pop_kitty_flags();
|
||||
}
|
||||
let _ = execute!(io::stdout(), DisableBracketedPaste);
|
||||
let _ = execute!(io::stdout(), DisableMouseCapture);
|
||||
ratatui::restore();
|
||||
|
||||
@@ -164,6 +169,7 @@ fn run(terminal: &mut ratatui::DefaultTerminal, mode: &mut Mode, ui: &mut Ui) ->
|
||||
Mode::Edit(ed) => match input_mode {
|
||||
InputMode::Editor => handle_editor_input(event, size.width, ed, ui),
|
||||
InputMode::Dialog => handle_dialog_input(event, ed),
|
||||
InputMode::CodeEditor => handle_code_editor_input(event, ed),
|
||||
_ => unreachable!(
|
||||
"Menu and Ignore handled above; Board/Scroll/Frozen input modes only occur in Play mode"
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user