first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
use galaxyui_core::text::TextBuffer;
use crate::vim::{Direction, FindCharDestination, FindCharMotion};
use galaxyui::text::TextBuffer;
/// Find the destination column for Vim's f/F/t/T motions on a single line.
///
+1 -1
View File
@@ -1,4 +1,4 @@
use galaxyui::text::TextBuffer;
use galaxyui_core::text::TextBuffer;
use itertools::Itertools;
use string_offset::CharOffset;
+1 -1
View File
@@ -1,4 +1,4 @@
use galaxyui::text::TextBuffer;
use galaxyui_core::text::TextBuffer;
use string_offset::CharOffset;
/// Returns the offset of the first newline above a paragraph start before the current position.
+3 -5
View File
@@ -2,14 +2,12 @@
use std::ops::Range;
use galaxyui::text::TextBuffer;
use galaxyui_core::text::TextBuffer;
use itertools::Itertools;
use string_offset::CharOffset;
use crate::{
vim::{BracketChar, BracketEnd, BracketType},
vim_find_matching_bracket,
};
use crate::vim::{BracketChar, BracketEnd, BracketType};
use crate::vim_find_matching_bracket;
/// Vim's block-based text objects, e.g. `di{`. This includes a string of text enclosed by any pair
/// of [`BracketType`], not including the brackets themselves.
+2 -1
View File
@@ -1,6 +1,7 @@
use super::*;
use unindent::Unindent;
use super::*;
const BLOCK: &str = "match BracketChar::try_from(c) {
Ok(bracket) => todo!(),
Err(_) => {
+2 -1
View File
@@ -7,7 +7,8 @@ mod paragraph;
mod quote;
mod word;
pub use self::block::*;
pub use paragraph::*;
pub use quote::*;
pub use word::*;
pub use self::block::*;
+1 -1
View File
@@ -1,6 +1,6 @@
use std::ops::Range;
use galaxyui::text::TextBuffer;
use galaxyui_core::text::TextBuffer;
use string_offset::CharOffset;
use crate::{find_next_paragraph_end, find_previous_paragraph_start};
+1 -1
View File
@@ -1,6 +1,6 @@
use std::ops::Range;
use galaxyui::text::TextBuffer;
use galaxyui_core::text::TextBuffer;
use itertools::Itertools;
use string_offset::CharOffset;
+3 -2
View File
@@ -1,9 +1,10 @@
use std::ops::Range;
use galaxyui::text::TextBuffer;
use galaxyui_core::text::TextBuffer;
use string_offset::CharOffset;
use crate::{vim::WordType, word_iterator::CharacterKind};
use crate::vim::WordType;
use crate::word_iterator::CharacterKind;
/// Vim's "inner word" text object, e.g. `diw`. This includes the series of either word chars,
/// symbols, or whitespace around the cursor.
+66 -8
View File
@@ -1,5 +1,6 @@
use galaxy_core::safe_info;
use galaxyui::{keymap::Keystroke, Entity, ModelContext, ModelHandle, ViewContext};
use galaxyui_core::keymap::Keystroke;
use galaxyui_core::{Entity, ModelContext, ModelHandle, ViewContext};
use crate::register::{valid_register_name, BLACK_HOLE_REGISTER};
@@ -245,6 +246,8 @@ enum PendingAction {
},
/// the full "g" command
G,
/// the full "z" command (e.g. zz)
Z,
FindChar {
direction: Direction,
destination: FindCharDestination,
@@ -269,6 +272,7 @@ impl From<char> for PendingAction {
pending_operand: None,
},
'g' => Self::G,
'z' => Self::Z,
'f' => Self::FindChar {
direction: Direction::Forward,
destination: FindCharDestination::AtChar,
@@ -586,6 +590,12 @@ pub enum VimEventType {
GotoDefinition,
FindReferences,
ShowHover,
/// Center the current line vertically in the viewport. Triggered by `zz`.
CenterCursorVertically,
/// Move cursor and scroll viewport down by half a page. Triggered by `<C-d>`.
ScrollHalfPageDown,
/// Move cursor and scroll viewport up by half a page. Triggered by `<C-u>`.
ScrollHalfPageUp,
}
impl VimEventType {
@@ -643,7 +653,10 @@ impl VimEventType {
| VimEventType::Escape
| VimEventType::GotoDefinition
| VimEventType::FindReferences
| VimEventType::ShowHover => None,
| VimEventType::ShowHover
| VimEventType::CenterCursorVertically
| VimEventType::ScrollHalfPageDown
| VimEventType::ScrollHalfPageUp => None,
}
}
}
@@ -699,7 +712,7 @@ impl VimFSA {
pending_operand_count: None,
pending_visual_object: None,
last_find_motion: None,
// When doing an operation that reads/writes to a register, the default (unnamed) regsiter
// When doing an operation that reads/writes to a register, the default (unnamed) register
// is called ".
register: '"',
dot_repeat_event: None,
@@ -795,6 +808,28 @@ impl VimFSA {
VimMode::Normal | VimMode::Visual(_) => self.typed_character('x')?,
VimMode::Replace => self.change_mode(VimMode::Normal.into()).into(),
},
"ctrl-d" => match self.mode {
VimMode::Normal | VimMode::Visual(_) => {
let count = self.get_action_count().unwrap_or(1);
self.clear();
VimEvent {
event_type: VimEventType::ScrollHalfPageDown,
count,
}
}
_ => return None,
},
"ctrl-u" => match self.mode {
VimMode::Normal | VimMode::Visual(_) => {
let count = self.get_action_count().unwrap_or(1);
self.clear();
VimEvent {
event_type: VimEventType::ScrollHalfPageUp,
count,
}
}
_ => return None,
},
_ => return None,
};
Some(event)
@@ -824,7 +859,7 @@ impl VimFSA {
}
}
/// Exiting insert mode is simple when it had been entered without a count, you just chenge the
/// Exiting insert mode is simple when it had been entered without a count, you just change the
/// mode. However, if there was a count, we need to repeat the text that was entered n - 1
/// times.
fn exit_insert_mode(&mut self) -> VimEvent {
@@ -917,7 +952,7 @@ impl VimFSA {
},
),
'r' => self.change_mode(VimMode::Replace.into()),
'g' | 'd' | 'c' | 'y' | 'f' | 'F' | 't' | 'T' | '[' | ']' | '"' => {
'g' | 'd' | 'c' | 'y' | 'z' | 'f' | 'F' | 't' | 'T' | '[' | ']' | '"' => {
self.pending_action = Some(PendingAction::from(c));
return None;
}
@@ -1025,6 +1060,13 @@ impl VimFSA {
action: PendingAction,
) -> Option<VimEventType> {
let event = match action {
PendingAction::Z => match c {
'z' => VimEventType::CenterCursorVertically,
_ => {
self.clear();
return None;
}
},
PendingAction::G => match c {
'e' | 'E' => VimEventType::Navigate(VimMotion::Word(WordMotion {
direction: Direction::Backward,
@@ -1467,7 +1509,7 @@ impl VimFSA {
write_register_name,
}
}
'g' | 'f' | 'F' | 't' | 'T' | '[' | ']' | '"' => {
'g' | 'z' | 'f' | 'F' | 't' | 'T' | '[' | ']' | '"' => {
self.pending_action = Some(PendingAction::from(c));
return None;
}
@@ -1502,6 +1544,13 @@ impl VimFSA {
pending_action: PendingAction,
) -> Option<VimEventType> {
let event_type = match pending_action {
PendingAction::Z => match c {
'z' => VimEventType::CenterCursorVertically,
_ => {
self.clear();
return None;
}
},
PendingAction::G => match c {
'e' | 'E' => VimEventType::Navigate(VimMotion::Word(WordMotion {
direction: Direction::Backward,
@@ -1744,7 +1793,7 @@ pub struct VimState<'a> {
pub showcmd: &'a str,
}
/// This struct is a wrapper around the VimFSA that turns it into a galaxyui::Entity. We want to keep
/// This struct is a wrapper around the VimFSA that turns it into a galaxyui_core::Entity. We want to keep
/// the VimFSA independent of our UI framework, so anything involving galaxyui should live here
/// instead.
#[derive(Default)]
@@ -1768,7 +1817,7 @@ impl VimModel {
}
pub fn keypress(&mut self, keystroke: &Keystroke, ctx: &mut ModelContext<Self>) {
if let Some(event) = self.fsa.keypress(keystroke.key.as_str()) {
if let Some(event) = self.fsa.keypress(keystroke.normalized().as_str()) {
ctx.emit(event);
}
}
@@ -1885,6 +1934,9 @@ where
VimEventType::GotoDefinition => self.goto_definition(ctx),
VimEventType::FindReferences => self.find_references(ctx),
VimEventType::ShowHover => self.show_hover(ctx),
VimEventType::CenterCursorVertically => self.center_cursor_vertically(ctx),
VimEventType::ScrollHalfPageDown => self.scroll_half_page_down(event.count, ctx),
VimEventType::ScrollHalfPageUp => self.scroll_half_page_up(event.count, ctx),
};
}
}
@@ -2003,4 +2055,10 @@ pub trait VimHandler {
fn find_references(&mut self, _ctx: &mut ViewContext<Self>) {}
/// Show hover information for the symbol under cursor (gh).
fn show_hover(&mut self, _ctx: &mut ViewContext<Self>) {}
/// Center the current line vertically in the viewport (zz).
fn center_cursor_vertically(&mut self, _ctx: &mut ViewContext<Self>) {}
/// Move the cursor down `count` half-pages and scroll the viewport (`<C-d>`).
fn scroll_half_page_down(&mut self, _count: u32, _ctx: &mut ViewContext<Self>) {}
/// Move the cursor up `count` half-pages and scroll the viewport (`<C-u>`).
fn scroll_half_page_up(&mut self, _count: u32, _ctx: &mut ViewContext<Self>) {}
}
+1 -1
View File
@@ -1,7 +1,7 @@
use std::iter::Peekable;
use anyhow::Result;
use galaxyui::text::{words::is_default_word_boundary, TextBuffer};
use galaxyui_core::text::{words::is_default_word_boundary, TextBuffer};
use itertools::{peek_nth, Either, PeekNth};
use string_offset::CharOffset;