From 3410a637b8f8b5b3f52dd101e9d97797ae2f8675 Mon Sep 17 00:00:00 2001 From: flauntingspade4 <48335751+flauntingspade4@users.noreply.github.com> Date: Mon, 11 Jan 2021 01:53:30 +0000 Subject: [PATCH 01/20] Fix some clippy warnings, and make slightly more consise --- src/oxa.rs | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/oxa.rs b/src/oxa.rs index 265eeed0..c836502b 100644 --- a/src/oxa.rs +++ b/src/oxa.rs @@ -79,22 +79,18 @@ pub fn interpret_line( } } _ => { - let i = match instruction { + let mut command = match instruction { "save" => save_command(&args), - "goto" => goto_command(&args), - "move" => move_command(&args), + "goto" => goto_command(&args)?, + "move" => move_command(&args)?, "put" => put_command(&args, &cursor), - "delete" => delete_command(&args, &cursor, graphemes, &rows), - "load" => load_command(&args), - "store" => store_command(&args), + "delete" => delete_command(&args, &cursor, graphemes, &rows)?, + "load" => load_command(&args)?, + "store" => store_command(&args)?, "overwrite" => overwrite_command(&args, &rows), _ => return None, }; - if let Some(mut command) = i { - events.append(&mut command); - } else { - return None; - } + events.append(&mut command); } } } @@ -174,8 +170,8 @@ fn set_command(args: &[&str], cursor: &Position, rows: &[Row]) -> Event { } } -fn overwrite_command(args: &[&str], rows: &[Row]) -> Option> { - Some(vec![if args.is_empty() { +fn overwrite_command(args: &[&str], rows: &[Row]) -> Vec { + vec![if args.is_empty() { Event::Overwrite(rows.to_vec(), vec![Row::from("")]) } else { Event::Overwrite( @@ -185,10 +181,10 @@ fn overwrite_command(args: &[&str], rows: &[Row]) -> Option> { .map(Row::from) .collect::>(), ) - }]) + }] } -fn save_command(args: &[&str]) -> Option> { +fn save_command(args: &[&str]) -> Vec { let mut events = vec![]; if args.is_empty() { events.push(Event::Save(None, false)) @@ -201,7 +197,7 @@ fn save_command(args: &[&str]) -> Option> { Event::Save(Some(args[0].to_string()), false) }) } - Some(events) + events } fn store_command(args: &[&str]) -> Option> { @@ -273,7 +269,7 @@ fn goto_command(args: &[&str]) -> Option> { Some(events) } -fn put_command(args: &[&str], cursor: &Position) -> Option> { +fn put_command(args: &[&str], cursor: &Position) -> Vec { let mut events = vec![]; if args[0] == "\\t" { events.push(Event::InsertTab(*cursor)); @@ -288,7 +284,7 @@ fn put_command(args: &[&str], cursor: &Position) -> Option> { )) } } - Some(events) + events } fn move_command(args: &[&str]) -> Option> { From 2a89c3db5516384fe9e56d054a0ca6deda12f9ea Mon Sep 17 00:00:00 2001 From: flauntingspade4 <48335751+flauntingspade4@users.noreply.github.com> Date: Mon, 11 Jan 2021 02:08:19 +0000 Subject: [PATCH 02/20] Remove some unnecessary `&`s, and add some `const fn`s --- src/config.rs | 8 +++--- src/document.rs | 28 +++++++++--------- src/editor.rs | 75 ++++++++++++++++++++++++------------------------ src/highlight.rs | 8 +++--- src/oxa.rs | 10 +++---- src/row.rs | 6 ++-- src/terminal.rs | 2 +- src/undo.rs | 2 +- src/util.rs | 2 +- 9 files changed, 70 insertions(+), 71 deletions(-) diff --git a/src/config.rs b/src/config.rs index bfa9ba80..be63c156 100644 --- a/src/config.rs +++ b/src/config.rs @@ -110,12 +110,12 @@ impl Reader { for expr in reg { if expr.starts_with("(?ms)") || expr.starts_with("(?sm)") { // Multiline regular expression - if let Ok(regx) = Regex::new(&expr) { + if let Ok(regx) = Regex::new(expr) { multi.push(regx); } } else { // Single line regular expression - if let Ok(regx) = Regex::new(&expr) { + if let Ok(regx) = Regex::new(expr) { single.push(regx); } } @@ -139,7 +139,7 @@ impl Reader { } result } - pub fn rgb_fg(colour: (u8, u8, u8)) -> SetForegroundColor { + pub const fn rgb_fg(colour: (u8, u8, u8)) -> SetForegroundColor { // Get the text ANSI code from an RGB value SetForegroundColor(Color::Rgb { r: colour.0, @@ -147,7 +147,7 @@ impl Reader { b: colour.2, }) } - pub fn rgb_bg(colour: (u8, u8, u8)) -> SetBackgroundColor { + pub const fn rgb_bg(colour: (u8, u8, u8)) -> SetBackgroundColor { // Get the background ANSI code from an RGB value SetBackgroundColor(Color::Rgb { r: colour.0, diff --git a/src/document.rs b/src/document.rs index 3b725f8d..9ee311f4 100644 --- a/src/document.rs +++ b/src/document.rs @@ -63,13 +63,13 @@ impl Document { rows: vec![Row::from("")], name: String::from("[No name]"), dirty: false, - cmd_line: Document::config_to_commandline(&status), + cmd_line: Self::config_to_commandline(status), path: String::new(), line_offset: config.general.line_number_padding_right + config.general.line_number_padding_left, undo_stack: EventStack::new(), redo_stack: EventStack::new(), - regex: Reader::get_syntax_regex(&config, ""), + regex: Reader::get_syntax_regex(config, ""), icon: String::new(), kind: String::new(), show_welcome: true, @@ -90,7 +90,7 @@ impl Document { // File exists let tabs = file.contains("\n\t"); let file = tabs_to_spaces(&file, config.general.tab_width); - let mut file = Document::split_file(&file); + let mut file = Self::split_file(&file); // Handle newline on last line if let Some(line) = file.iter().last() { if line.is_empty() { @@ -101,23 +101,23 @@ impl Document { if file.is_empty() { file.push(""); } - let ext = path.split('.').last().unwrap_or(&""); + let extension = path.split('.').last().unwrap_or(""); Some(Self { rows: file.iter().map(|row| Row::from(*row)).collect(), name: Path::new(path) .file_name() .unwrap_or_else(|| OsStr::new(path)) .to_str() - .unwrap_or(&path) + .unwrap_or(path) .to_string(), dirty: false, - cmd_line: Document::config_to_commandline(&status), + cmd_line: Self::config_to_commandline(status), path: path.to_string(), line_offset: config.general.line_number_padding_right + config.general.line_number_padding_left, undo_stack: EventStack::new(), redo_stack: EventStack::new(), - regex: Reader::get_syntax_regex(&config, ext), + regex: Reader::get_syntax_regex(config, extension), kind: Self::identify(path).0.to_string(), icon: Self::identify(path).1.to_string(), show_welcome: false, @@ -138,24 +138,24 @@ impl Document { // Create a new document from a path with empty document on error let true_path = path.to_string(); let path = path.split(':').next().unwrap(); - if let Some(doc) = Document::open(&config, &status, &true_path, read_only) { + if let Some(doc) = Self::open(config, status, &true_path, read_only) { log!("Opening file", "File was found"); doc } else { // Create blank document log!("Opening file", "File not found"); - let ext = path.split('.').last().unwrap_or(&""); + let ext = path.split('.').last().unwrap_or(""); Self { rows: vec![Row::from("")], name: path.to_string(), path: path.to_string(), dirty: false, - cmd_line: Document::config_to_commandline(&status), + cmd_line: Self::config_to_commandline(status), line_offset: config.general.line_number_padding_right + config.general.line_number_padding_left, undo_stack: EventStack::new(), redo_stack: EventStack::new(), - regex: Reader::get_syntax_regex(&config, ext), + regex: Reader::get_syntax_regex(config, ext), kind: Self::identify(path).0.to_string(), icon: Self::identify(path).1.to_string(), show_welcome: false, @@ -265,9 +265,9 @@ impl Document { } Key::Up => { // Move the cursor up - if self.cursor.y - OFFSET == 0 { + if self.cursor.y == OFFSET { self.offset.y = self.offset.y.saturating_sub(1); - } else if self.cursor.y != OFFSET { + } else { self.cursor.y = self.cursor.y.saturating_sub(1); } self.snap_cursor(term); @@ -586,7 +586,7 @@ impl Document { Event::InsertTab(pos) => { self.dirty = true; self.goto(pos, term); - self.tab(&pos, &config, term); + self.tab(&pos, config, term); if !reversed { self.undo_stack.push(event); } diff --git a/src/editor.rs b/src/editor.rs index 455d748e..524fff15 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -259,7 +259,7 @@ impl Editor { } } } - fn key_event_to_ox_key(key: KeyCode, modifiers: KeyModifiers) -> KeyBinding { + const fn key_event_to_ox_key(key: KeyCode, modifiers: KeyModifiers) -> KeyBinding { // Convert crossterm's complicated key structure into Ox's simpler one let inner = match key { KeyCode::Char(c) => RawKey::Char(c), @@ -297,7 +297,7 @@ impl Editor { x: cursor.x + offset.x, y: cursor.y + offset.y - OFFSET, }; - let ox_key = Editor::key_event_to_ox_key(key.code, key.modifiers); + let ox_key = Self::key_event_to_ox_key(key.code, key.modifiers); self.keypress = ox_key; match ox_key { KeyBinding::Raw(RawKey::Enter) => { @@ -449,7 +449,7 @@ impl Editor { let tab_width = self.config.general.tab_width; if self.doc[self.tab].save(&save, tab_width).is_ok() { // The document saved successfully - let ext = save.split('.').last().unwrap_or(&""); + let ext = save.split('.').last().unwrap_or(""); self.doc[self.tab].dirty = false; self.doc[self.tab].set_command_line( format!("File saved to \"{}\" successfully", save), @@ -552,7 +552,7 @@ impl Editor { } pub fn execute(&mut self, event: Event, reversed: bool) { // Event executor - if self.doc[self.tab].read_only && Editor::will_edit(&event) { + if self.doc[self.tab].read_only && Self::will_edit(&event) { return; } match event { @@ -584,7 +584,7 @@ impl Editor { Event::MoveWord(direction) => match direction { Direction::Left => self.doc[self.tab].word_left(&self.term.size), Direction::Right => self.doc[self.tab].word_right(&self.term.size), - _ => {}, + _ => {} }, Event::GotoCursor(pos) => { let rows = &self.doc[self.tab].rows; @@ -712,7 +712,7 @@ impl Editor { // Execute the instruction if let Some(instruct) = instruction { for i in instruct { - if Editor::will_edit(&i) { + if Self::will_edit(&i) { self.doc[self.tab].redo_stack.empty(); } self.execute(i, false); @@ -722,20 +722,23 @@ impl Editor { } } } - pub fn will_edit(event: &Event) -> bool { - matches!(event, Event::SpliceUp(_, _) - | Event::SplitDown(_, _) - | Event::InsertLineAbove(_) - | Event::InsertLineBelow(_) - | Event::Deletion(_, _) - | Event::Insertion(_, _) - | Event::InsertTab(_) - | Event::DeleteTab(_) - | Event::DeleteLine(_, _, _) - | Event::UpdateLine(_, _, _, _) - | Event::ReplaceAll - | Event::Replace - | Event::Overwrite(_, _)) + pub const fn will_edit(event: &Event) -> bool { + matches!( + event, + Event::SpliceUp(_, _) + | Event::SplitDown(_, _) + | Event::InsertLineAbove(_) + | Event::InsertLineBelow(_) + | Event::Deletion(_, _) + | Event::Insertion(_, _) + | Event::InsertTab(_) + | Event::DeleteTab(_) + | Event::DeleteLine(_, _, _) + | Event::UpdateLine(_, _, _, _) + | Event::ReplaceAll + | Event::Replace + | Event::Overwrite(_, _) + ) } pub fn undo(&mut self) { self.doc[self.tab].undo_stack.commit(); @@ -827,14 +830,14 @@ impl Editor { if let Some(p) = s.doc[s.tab].find_prev(t, ¤t) { s.doc[s.tab].goto(p, &s.term.size); s.refresh_view(); - s.highlight_bg_tokens(&t, p); + s.highlight_bg_tokens(t, p); } } KeyCode::Down | KeyCode::Right => { if let Some(p) = s.doc[s.tab].find_next(t, ¤t) { s.doc[s.tab].goto(p, &s.term.size); s.refresh_view(); - s.highlight_bg_tokens(&t, p); + s.highlight_bg_tokens(t, p); } } KeyCode::Esc => { @@ -846,15 +849,15 @@ impl Editor { PromptEvent::CharPress(backspace) => { // Highlight the tokens if backspace { - s.highlight_bg_tokens(&t, initial); + s.highlight_bg_tokens(t, initial); } if let Some(p) = s.doc[s.tab].find_next(t, &initial) { s.doc[s.tab].goto(p, &s.term.size); s.refresh_view(); - s.highlight_bg_tokens(&t, p); + s.highlight_bg_tokens(t, p); } else { s.doc[s.tab].goto(initial, &s.term.size); - s.highlight_bg_tokens(&t, initial); + s.highlight_bg_tokens(t, initial); } } PromptEvent::Update => (), @@ -992,22 +995,18 @@ impl Editor { modifiers: m, }) = self.read_event() { - let ox_key = Editor::key_event_to_ox_key(c, m); + let ox_key = Self::key_event_to_ox_key(c, m); match ox_key { KeyBinding::Raw(RawKey::Enter) => return true, KeyBinding::Ctrl(_) | KeyBinding::Alt(_) => { if ox_key == key { return true; - } else { - self.doc[self.tab].set_command_line( - format!("{} cancelled", title(subject)), - Type::Info, - ); } } - _ => self.doc[self.tab] - .set_command_line(format!("{} cancelled", title(subject)), Type::Info), + _ => {} } + self.doc[self.tab] + .set_command_line(format!("{} cancelled", title(subject)), Type::Info) } } else { return true; @@ -1030,7 +1029,7 @@ impl Editor { modifiers: m, }) = self.read_event() { - match Editor::key_event_to_ox_key(c, m) { + match Self::key_event_to_ox_key(c, m) { KeyBinding::Raw(RawKey::Enter) => { // Exit on enter key break 'p; @@ -1149,7 +1148,7 @@ impl Editor { "{}{}{}{}", Reader::rgb_bg(self.config.theme.editor_bg), text, - self.term.align_left(&text), + self.term.align_left(text), RESET_BG ) } @@ -1163,7 +1162,7 @@ impl Editor { "{}{}{}{}{}", Attribute::Bold, Reader::rgb_fg(self.config.theme.error_fg), - self.add_background(&trim_end(&line, self.term.size.width)), + self.add_background(&trim_end(line, self.term.size.width)), RESET_FG, Attribute::Reset )), @@ -1171,14 +1170,14 @@ impl Editor { "{}{}{}{}{}", Attribute::Bold, Reader::rgb_fg(self.config.theme.warning_fg), - self.add_background(&trim_end(&line, self.term.size.width)), + self.add_background(&trim_end(line, self.term.size.width)), RESET_FG, Attribute::Reset )), Type::Info => self.add_background(&format!( "{}{}{}", Reader::rgb_fg(self.config.theme.info_fg), - self.add_background(&trim_end(&line, self.term.size.width)), + self.add_background(&trim_end(line, self.term.size.width)), RESET_FG, )), } diff --git a/src/highlight.rs b/src/highlight.rs index d6ef2edc..06f15d22 100644 --- a/src/highlight.rs +++ b/src/highlight.rs @@ -32,7 +32,7 @@ fn bounds(reg: ®ex::Match, line: &str) -> (usize, usize) { fn multi_to_single(doc: &str, m: ®ex::Match) -> ((usize, usize), (usize, usize)) { // Multiline tokens to single line tokens - let b = bounds(&m, &doc); + let b = bounds(m, doc); let start_y = doc[..m.start()].matches('\n').count(); let end_y = doc[..m.end()].matches('\n').count(); let start_x = b.0 @@ -63,7 +63,7 @@ pub fn highlight( // Locate keywords for cap in kw.captures_iter(row) { let cap = cap.get(cap.len().saturating_sub(1)).unwrap(); - let boundaries = bounds(&cap, &row); + let boundaries = bounds(&cap, row); cine( &Token { span: boundaries, @@ -80,7 +80,7 @@ pub fn highlight( // Locate expressions for cap in exp.captures_iter(row) { let cap = cap.get(cap.len().saturating_sub(1)).unwrap(); - let boundaries = bounds(&cap, &row); + let boundaries = bounds(&cap, row); cine( &Token { span: boundaries, @@ -99,7 +99,7 @@ pub fn highlight( for exp in regex { for cap in exp.captures_iter(doc) { let cap = cap.get(cap.len().saturating_sub(1)).unwrap(); - let ((start_x, start_y), (end_x, end_y)) = multi_to_single(&doc, &cap); + let ((start_x, start_y), (end_x, end_y)) = multi_to_single(doc, &cap); if start_y == index { cine( &Token { diff --git a/src/oxa.rs b/src/oxa.rs index c836502b..c761e82c 100644 --- a/src/oxa.rs +++ b/src/oxa.rs @@ -42,7 +42,7 @@ pub fn interpret_line( "quit" => events.push(quit_command(&args)), "prev" => events.push(Event::PrevTab), "next" => events.push(Event::NextTab), - "set" => events.push(set_command(&args, &cursor, &rows)), + "set" => events.push(set_command(&args, cursor, rows)), "split" => events.push(Event::SplitDown(*cursor, *cursor)), "splice" => events.push(Event::SpliceUp(*cursor, *cursor)), "search" => events.push(Event::Search), @@ -72,7 +72,7 @@ pub fn interpret_line( } } "line" => { - if let Some(line) = line_command(&args, &cursor) { + if let Some(line) = line_command(&args, cursor) { events.push(line); } else { return None; @@ -83,11 +83,11 @@ pub fn interpret_line( "save" => save_command(&args), "goto" => goto_command(&args)?, "move" => move_command(&args)?, - "put" => put_command(&args, &cursor), - "delete" => delete_command(&args, &cursor, graphemes, &rows)?, + "put" => put_command(&args, cursor), + "delete" => delete_command(&args, cursor, graphemes, rows)?, "load" => load_command(&args)?, "store" => store_command(&args)?, - "overwrite" => overwrite_command(&args, &rows), + "overwrite" => overwrite_command(&args, rows), _ => return None, }; events.append(&mut command); diff --git a/src/row.rs b/src/row.rs index ef4cbec7..f1764ffa 100644 --- a/src/row.rs +++ b/src/row.rs @@ -71,7 +71,7 @@ impl Row { let index = index.saturating_add(1); // Padding to align line numbers to the right // Assemble the line number data - let line_number = Row::render_line_number(config, offset, index); + let line_number = Self::render_line_number(config, offset, index); // Strip ANSI values from the line let line_number_len = self.regex.ansi_len(&line_number); let width = width.saturating_sub(line_number_len); @@ -188,9 +188,9 @@ impl Row { self.syntax = remove_nested_tokens( &highlight( &self.string, - &doc, + doc, index, - &syntax, + syntax, &config.highlights[theme], ), &self.string, diff --git a/src/terminal.rs b/src/terminal.rs index 02247331..0ee82bc5 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -25,7 +25,7 @@ impl Terminal { pub fn new() -> Result { // Create a new terminal and switch into raw mode let size = terminal::size()?; - Terminal::enter(); + Self::enter(); Ok(Self { size: Size { width: size.0 as usize, diff --git a/src/undo.rs b/src/undo.rs index 7b1059c8..7698c2ed 100644 --- a/src/undo.rs +++ b/src/undo.rs @@ -63,7 +63,7 @@ pub struct EventStack { // Methods for the EventStack impl EventStack { - pub fn new() -> Self { + pub const fn new() -> Self { // Initialise an Event stack Self { history: vec![], diff --git a/src/util.rs b/src/util.rs index eddc2243..c571ad94 100644 --- a/src/util.rs +++ b/src/util.rs @@ -54,7 +54,7 @@ pub fn trim_end(text: &str, end: usize) -> String { result.join("") } -pub fn line_offset(point: usize, offset: i128, limit: usize) -> usize { +pub const fn line_offset(point: usize, offset: i128, limit: usize) -> usize { if offset.is_negative() { if point as i128 + offset >= 0 { (point as i128 + offset) as usize From 988e502f5a3ea3dfe4709e72059c3bf0081f7ebc Mon Sep 17 00:00:00 2001 From: flauntingspade4 <48335751+flauntingspade4@users.noreply.github.com> Date: Mon, 11 Jan 2021 02:21:04 +0000 Subject: [PATCH 03/20] A small change to prevent a `.clone()` while highlighting This may break things further on in development, but currently makes no difference --- src/highlight.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/highlight.rs b/src/highlight.rs index 06f15d22..bb807eaa 100644 --- a/src/highlight.rs +++ b/src/highlight.rs @@ -12,14 +12,14 @@ pub struct Token { pub priority: usize, } -pub fn cine(token: &Token, hashmap: &mut HashMap) { +pub fn cine(token: Token, hashmap: &mut HashMap) { // Insert a token into a hashmap if let Some(t) = hashmap.get(&token.span.0) { if t.priority > token.priority { return; } } - hashmap.insert(token.span.0, token.clone()); + hashmap.insert(token.span.0, token); } fn bounds(reg: ®ex::Match, line: &str) -> (usize, usize) { @@ -65,7 +65,7 @@ pub fn highlight( let cap = cap.get(cap.len().saturating_sub(1)).unwrap(); let boundaries = bounds(&cap, row); cine( - &Token { + Token { span: boundaries, data: cap.as_str().to_string(), kind: Reader::rgb_fg(highlights["keywords"]).to_string(), @@ -82,7 +82,7 @@ pub fn highlight( let cap = cap.get(cap.len().saturating_sub(1)).unwrap(); let boundaries = bounds(&cap, row); cine( - &Token { + Token { span: boundaries, data: cap.as_str().to_string(), kind: Reader::rgb_fg(highlights[name]).to_string(), @@ -102,7 +102,7 @@ pub fn highlight( let ((start_x, start_y), (end_x, end_y)) = multi_to_single(doc, &cap); if start_y == index { cine( - &Token { + Token { span: ( start_x, if start_y == end_y { @@ -119,7 +119,7 @@ pub fn highlight( ) } else if end_y == index { cine( - &Token { + Token { span: (0, end_x), data: row.to_string(), kind: Reader::rgb_fg(highlights[name]).to_string(), @@ -129,7 +129,7 @@ pub fn highlight( ) } else if (start_y..=end_y).contains(&index) { cine( - &Token { + Token { span: (0, UnicodeWidthStr::width(row)), data: row.to_string(), kind: Reader::rgb_fg(highlights[name]).to_string(), From 248ac60857b98d08903d714df805bf175f642bbb Mon Sep 17 00:00:00 2001 From: flauntingspade4 <48335751+flauntingspade4@users.noreply.github.com> Date: Mon, 11 Jan 2021 16:51:12 +0000 Subject: [PATCH 04/20] Get rid of 3 `.clone()` calls, and simplify `load_config` --- src/editor.rs | 6 +++--- src/main.rs | 5 +---- src/undo.rs | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 524fff15..bf6acbad 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -218,13 +218,13 @@ impl Editor { doc: documents, last_keypress: None, keypress: KeyBinding::Unsupported, - config: config.0.clone(), + theme: config.0.theme.default_theme.clone(), + config: config.0, config_path: config_path.to_string(), status: config.1, exp: Exp::new(), position_bank: HashMap::new(), row_bank: HashMap::new(), - theme: config.0.theme.default_theme, }) } pub fn run(&mut self) { @@ -465,8 +465,8 @@ impl Editor { .to_str() .unwrap_or(&save) .to_string(); - self.doc[self.tab].path = save.clone(); self.doc[self.tab].regex = Reader::get_syntax_regex(&self.config, ext); + self.doc[self.tab].path = save; } else if save.is_empty() { // The document couldn't save due to an empty name self.doc[self.tab].set_command_line( diff --git a/src/main.rs b/src/main.rs index 92057a23..f3757eaf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -114,8 +114,5 @@ file.txt:100 (This will go to line 100 in file.txt)"#, fn load_config() -> Option { // Load the configuration file let base_dirs = BaseDirs::new()?; - Some(format!( - "{}/ox/ox.ron", - base_dirs.config_dir().to_str()?.to_string() - )) + Some(format!("{}/ox/ox.ron", base_dirs.config_dir().to_str()?)) } diff --git a/src/undo.rs b/src/undo.rs index 7698c2ed..95605ffb 100644 --- a/src/undo.rs +++ b/src/undo.rs @@ -89,8 +89,8 @@ impl EventStack { pub fn commit(&mut self) { // Commit patch to history if !self.current_patch.is_empty() { - self.history.push(self.current_patch.clone()); - self.current_patch.clear(); + let current_patch = std::mem::replace(&mut self.current_patch, Vec::new()); + self.history.push(current_patch); } } pub fn len(&self) -> usize { From 2e6b1e0d598443525f14c421663a1a6e9cd5a9d2 Mon Sep 17 00:00:00 2001 From: flauntingspade4 <48335751+flauntingspade4@users.noreply.github.com> Date: Mon, 11 Jan 2021 23:48:10 +0000 Subject: [PATCH 05/20] Small fix for Windows `ox.log` is no longer saved in `/tmp/ox.log`. It is instead saved in `format!("{}/ox/ox.log", Basedirs::new().config_dir())` This allows ox to be more cross-compatiable --- src/document.rs | 1 + src/editor.rs | 1 + src/main.rs | 9 +++++---- src/row.rs | 8 +------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/document.rs b/src/document.rs index 9ee311f4..bc56f238 100644 --- a/src/document.rs +++ b/src/document.rs @@ -4,6 +4,7 @@ use crate::editor::OFFSET; use crate::util::{line_offset, spaces_to_tabs, tabs_to_spaces}; use crate::{log, Editor, Event, EventStack, Position, Row, Size, Variable, VERSION}; use crossterm::event::KeyCode as Key; +use directories::BaseDirs; use regex::Regex; use std::ffi::OsStr; use std::fs::OpenOptions; diff --git a/src/editor.rs b/src/editor.rs index bf6acbad..b1857e94 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -10,6 +10,7 @@ use clap::App; use crossterm::event::{Event as InputEvent, KeyCode, KeyEvent, KeyModifiers}; use crossterm::style::{Attribute, Color, SetBackgroundColor, SetForegroundColor}; use crossterm::ErrorKind; +use directories::BaseDirs; use regex::Regex; use std::collections::HashMap; use std::ffi::OsStr; diff --git a/src/main.rs b/src/main.rs index f3757eaf..fac9e8eb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,10 +46,11 @@ use undo::{Event, EventStack}; #[macro_export] macro_rules! log { ($type:literal, $msg:expr) => { - let file = OpenOptions::new() - .create(true) - .append(true) - .open("/tmp/ox.log"); + let base_dirs = BaseDirs::new().unwrap(); + let file = OpenOptions::new().create(true).append(true).open(format!( + "{}/ox/ox.log", + base_dirs.config_dir().to_str().unwrap() + )); if let Ok(mut log) = file { writeln!(log, "{}: {}", $type, $msg).unwrap(); } else { diff --git a/src/row.rs b/src/row.rs index f1764ffa..a2f1810b 100644 --- a/src/row.rs +++ b/src/row.rs @@ -186,13 +186,7 @@ impl Row { ) { // Update the syntax highlighting indices for this row self.syntax = remove_nested_tokens( - &highlight( - &self.string, - doc, - index, - syntax, - &config.highlights[theme], - ), + &highlight(&self.string, doc, index, syntax, &config.highlights[theme]), &self.string, ); } From 8ea34cc04a74414d3a71f7b36db70f3511018391 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Tue, 30 Apr 2024 00:13:32 -0400 Subject: [PATCH 06/20] Create rust.yml --- .github/workflows/rust.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 00000000..000bb2c4 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,22 @@ +name: Rust + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose From 4a78ecb8c6db01315fd0d40f918c088cb7069ff5 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Tue, 30 Apr 2024 00:13:58 -0400 Subject: [PATCH 07/20] Create devskim.yml --- .github/workflows/devskim.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/devskim.yml diff --git a/.github/workflows/devskim.yml b/.github/workflows/devskim.yml new file mode 100644 index 00000000..070b22f8 --- /dev/null +++ b/.github/workflows/devskim.yml @@ -0,0 +1,34 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: DevSkim + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '23 18 * * 4' + +jobs: + lint: + name: DevSkim + runs-on: ubuntu-20.04 + permissions: + actions: read + contents: read + security-events: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run DevSkim scanner + uses: microsoft/DevSkim-Action@v1 + + - name: Upload DevSkim scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: devskim-results.sarif From 8adbfb85c633785db084c21932d21ce955c58c22 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Tue, 30 Apr 2024 12:29:24 -0400 Subject: [PATCH 08/20] Fix config dir creation if not exist --- src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.rs b/src/main.rs index fac9e8eb..f14c6728 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,6 +41,7 @@ use std::io::Write; use std::{env, panic}; use terminal::{Size, Terminal}; use undo::{Event, EventStack}; +use std::fs; // Create log macro #[macro_export] @@ -63,6 +64,11 @@ macro_rules! log { pub const VERSION: &str = env!("CARGO_PKG_VERSION"); fn main() { +let base_dirs = BaseDirs::new().unwrap(); +let _ = fs::create_dir_all(format!( + "{}/ox/", + base_dirs.config_dir().to_str().unwrap())); +println!("{}", base_dirs.config_dir().to_str().unwrap()); log!("Ox started", "Ox has just been started"); // Set up panic hook in case of unexpected crash panic::set_hook(Box::new(|e| { From 0433693ffabbbf40843f5550d249d9203d859c38 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Tue, 30 Apr 2024 12:49:27 -0400 Subject: [PATCH 09/20] Fix Create config dir if not exist --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f14c6728..66b8a81a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,7 @@ fn main() { let base_dirs = BaseDirs::new().unwrap(); let _ = fs::create_dir_all(format!( "{}/ox/", - base_dirs.config_dir().to_str().unwrap())); + base_dirs.config_dir().to_str().unwrap())); println!("{}", base_dirs.config_dir().to_str().unwrap()); log!("Ox started", "Ox has just been started"); // Set up panic hook in case of unexpected crash From d808a302e27bce30f94c6e442dfa0ce620317e0e Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Tue, 30 Apr 2024 13:28:52 -0400 Subject: [PATCH 10/20] fix test log --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 66b8a81a..a6ac45e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,7 @@ let base_dirs = BaseDirs::new().unwrap(); let _ = fs::create_dir_all(format!( "{}/ox/", base_dirs.config_dir().to_str().unwrap())); -println!("{}", base_dirs.config_dir().to_str().unwrap()); + log!("Ox started", "Ox has just been started"); // Set up panic hook in case of unexpected crash panic::set_hook(Box::new(|e| { From 12eac21eef3a4fee82f38690b8eb627b9b43f8f1 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 15:05:48 -0400 Subject: [PATCH 11/20] add delete and fix undo --- src/document.rs | 12 ++++++++++++ src/editor.rs | 27 ++++++++++++++++++++++++++- src/row.rs | 1 + src/undo.rs | 2 ++ test.txt | 3 +++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test.txt diff --git a/src/document.rs b/src/document.rs index bc56f238..0f559144 100644 --- a/src/document.rs +++ b/src/document.rs @@ -563,6 +563,18 @@ impl Document { } self.rows[pos.y].delete(self.graphemes.saturating_sub(1)); } + Event::DeletionFw(pos, _) => { + self.dirty = true; + self.show_welcome = false; + self.recalculate_graphemes(); + self.goto(pos, term); + if reversed { + self.move_cursor(Key::Left, term, config.general.wrap_cursor); + } else { + self.undo_stack.push(event); + } + self.rows[pos.y].delete(self.graphemes); + } Event::InsertLineAbove(pos) => { self.dirty = true; self.rows.insert(pos.y, Row::from("")); diff --git a/src/editor.rs b/src/editor.rs index b1857e94..543f4bcb 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -332,7 +332,7 @@ impl Editor { let row = self.doc[self.tab].rows[current.y].clone(); let chr = row .ext_chars() - .get(current.x.saturating_add(1)) + .get(current.x.saturating_sub(1)) .map_or(" ", |chr| *chr); let current = Position { x: current.x.saturating_sub(UnicodeWidthStr::width(chr)), @@ -343,6 +343,31 @@ impl Editor { false, ); } + KeyBinding::Raw(RawKey::Delete) => { + self.doc[self.tab].redo_stack.empty(); + self.execute( + /*if current.x == 0 && current.y != 0 { + // Backspace at the start of a line + Event::SpliceUp(current, current) + } else if current.x == 0 { + return; + } else { + */ // Backspace in the middle of a line + { + let row = self.doc[self.tab].rows[current.y].clone(); + let chr = row + .ext_chars() + .get(current.x)//.saturating_add(1)) + .map_or(" ", |chr| *chr); + let current = Position { + x: current.x,//.saturating_add(1),//saturating_sub(UnicodeWidthStr::width(chr)), + y: current.y, + }; + Event::DeletionFw(current, chr.parse().unwrap_or(' ')) + }, + false, + ); + } // Detect control and alt and function key bindings KeyBinding::Ctrl(_) | KeyBinding::Alt(_) | KeyBinding::F(_) => { if let Some(commands) = self.config.keys.get(&ox_key) { diff --git a/src/row.rs b/src/row.rs index a2f1810b..5e9c3feb 100644 --- a/src/row.rs +++ b/src/row.rs @@ -238,6 +238,7 @@ impl Row { self.updated = true; let before: String = self.string.graphemes(true).take(pos as usize).collect(); let after: String = self.string.graphemes(true).skip(1 + pos as usize).collect(); + let result: Option; if let Some(c) = self.chars().get(pos) { if let Ok(c) = c.parse() { diff --git a/src/undo.rs b/src/undo.rs index 95605ffb..bd4d2c25 100644 --- a/src/undo.rs +++ b/src/undo.rs @@ -19,6 +19,7 @@ pub enum Event { InsertLineAbove(Position), // Return key in the middle of line InsertLineBelow(Position), // Return on the end of line Deletion(Position, char), // Delete from middle + DeletionFw(Position, char), // Delete from middle Insertion(Position, char), // Insert character InsertTab(Position), // Insert a tab character DeleteTab(Position), // Delete a tab character @@ -108,6 +109,7 @@ pub fn reverse(before: Event, limit: usize) -> Option> { Event::InsertLineAbove(pos) => vec![Event::DeleteLine(pos, 0, Box::new(Row::from("")))], Event::InsertLineBelow(pos) => vec![Event::DeleteLine(pos, 1, Box::new(Row::from("")))], Event::Deletion(pos, ch) => vec![Event::Insertion(pos, ch)], + Event::DeletionFw(pos, ch) => vec![Event::Insertion(pos, ch)], Event::Insertion(pos, ch) => vec![Event::Deletion( Position { x: pos.x.saturating_add(1), diff --git a/test.txt b/test.txt new file mode 100644 index 00000000..61fe7b68 --- /dev/null +++ b/test.txt @@ -0,0 +1,3 @@ +efeerererererregretyer4ty +wtywretywtywtywtywtreywtywty +wtywtywtyw4teywywtywteywtyty From a7bd84941ae1a36434b60553d28919ac9f8d57e4 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 15:52:55 -0400 Subject: [PATCH 12/20] Update to crossterm = "0.27.0" --- Cargo.lock | 276 +++++++++++++++++++++++++++++++++--------------- Cargo.toml | 2 +- src/editor.rs | 9 +- src/terminal.rs | 5 +- 4 files changed, 204 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19554fdb..6b57207a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" version = "0.7.15" @@ -59,6 +61,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + [[package]] name = "blake2b_simd" version = "0.5.11" @@ -90,22 +98,13 @@ checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.2.1", "strsim", "textwrap", "unicode-width", "vec_map", ] -[[package]] -name = "cloudabi" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" -dependencies = [ - "bitflags", -] - [[package]] name = "constant_time_eq" version = "0.1.5" @@ -125,25 +124,25 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.18.2" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e86d73f2a0b407b5768d10a8c720cf5d2df49a9efc10ca09176d201ead4b7fb" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags", + "bitflags 2.5.0", "crossterm_winapi", - "lazy_static", "libc", "mio", "parking_lot", "signal-hook", + "signal-hook-mio", "winapi", ] [[package]] name = "crossterm_winapi" -version = "0.6.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2265c3f8e080075d9b6417aa72293fc71662f34b4af2612d8d1b074d29510db" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ "winapi", ] @@ -186,7 +185,7 @@ checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ "cfg-if 0.1.10", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] @@ -198,15 +197,6 @@ dependencies = [ "libc", ] -[[package]] -name = "instant" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" -dependencies = [ - "cfg-if 1.0.0", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -215,15 +205,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.80" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "lock_api" -version = "0.4.1" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] @@ -245,34 +235,14 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "mio" -version = "0.7.6" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f33bc887064ef1fd66020c9adfc45bb9f33d75a42096c81e7c56c65b75dd1a8b" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "miow", - "ntapi", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" -dependencies = [ - "socket2", - "winapi", -] - -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", ] [[package]] @@ -293,28 +263,25 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.0" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "instant", + "cfg-if 1.0.0", "libc", - "redox_syscall", + "redox_syscall 0.5.1", "smallvec", - "winapi", + "windows-targets 0.52.5", ] [[package]] @@ -341,6 +308,15 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" version = "0.3.5" @@ -348,7 +324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.1.57", "rust-argon2", ] @@ -377,7 +353,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8a58080b7bb83b2ea28c3b7a9a994fd5e310330b7c8ca5258d99b98128ecfe4" dependencies = [ "base64", - "bitflags", + "bitflags 1.2.1", "serde", ] @@ -430,42 +406,40 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.1.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", - "mio", "signal-hook-registry", ] [[package]] -name = "signal-hook-registry" -version = "1.2.2" +name = "signal-hook-mio" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", + "mio", + "signal-hook", ] [[package]] -name = "smallvec" +name = "signal-hook-registry" version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" - -[[package]] -name = "socket2" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd8b795c389288baa5f355489c65e71fd48a02104600d15c4cfbc561e9e429d" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ - "cfg-if 0.1.10", "libc", - "redox_syscall", - "winapi", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "strsim" version = "0.8.0" @@ -541,6 +515,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "winapi" version = "0.3.9" @@ -562,3 +542,133 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/Cargo.toml b/Cargo.toml index cb16e2ee..24a85fda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ ron = "0.6.2" serde = "1.0.117" regex = "1.4.2" directories = "3.0.1" -crossterm = "0.18.2" +crossterm = "0.27.0" term = "0.6.1" [package.metadata.rpm] diff --git a/src/editor.rs b/src/editor.rs index 543f4bcb..27257050 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -9,7 +9,6 @@ use crate::{log, Document, Event, Row, Size, Terminal, VERSION}; use clap::App; use crossterm::event::{Event as InputEvent, KeyCode, KeyEvent, KeyModifiers}; use crossterm::style::{Attribute, Color, SetBackgroundColor, SetForegroundColor}; -use crossterm::ErrorKind; use directories::BaseDirs; use regex::Regex; use std::collections::HashMap; @@ -126,7 +125,7 @@ pub struct Editor { // Implementing methods for our editor struct / class impl Editor { - pub fn new(args: App) -> Result { + pub fn new(args: App) -> Result { // Create a new editor instance let args = args.get_matches(); // Set up terminal @@ -281,6 +280,7 @@ impl Editor { KeyCode::Left => RawKey::Left, KeyCode::Right => RawKey::Right, KeyCode::F(i) => return KeyBinding::F(i), + _ => todo!(), }; match modifiers { KeyModifiers::CONTROL => KeyBinding::Ctrl(inner), @@ -417,6 +417,7 @@ impl Editor { self.update(); } InputEvent::Mouse(_) => (), + crossterm::event::Event::FocusGained | crossterm::event::Event::FocusLost | crossterm::event::Event::Paste(_) => todo!(), } } fn new_document(&mut self) { @@ -1019,6 +1020,8 @@ impl Editor { if let InputEvent::Key(KeyEvent { code: c, modifiers: m, + kind: _k, + state: _s, }) = self.read_event() { let ox_key = Self::key_event_to_ox_key(c, m); @@ -1053,6 +1056,8 @@ impl Editor { if let InputEvent::Key(KeyEvent { code: c, modifiers: m, + kind: _k, + state: _s, }) = self.read_event() { match Self::key_event_to_ox_key(c, m) { diff --git a/src/terminal.rs b/src/terminal.rs index 0ee82bc5..fed61c57 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -2,7 +2,8 @@ use crate::util::Exp; use crate::Position; use crossterm::terminal; -use crossterm::{execute, ErrorKind}; +use crossterm::{execute}; +use std::io::Error; use std::env; use std::io::{stdout, Write}; use term::terminfo::TermInfo; @@ -22,7 +23,7 @@ pub struct Terminal { // Implement methods into the terminal struct / class impl Terminal { - pub fn new() -> Result { + pub fn new() -> Result { // Create a new terminal and switch into raw mode let size = terminal::size()?; Self::enter(); From d5f19ef93d4a8df7a50f6f76c6427939b4c215ac Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 15:55:14 -0400 Subject: [PATCH 13/20] Update unicode-segmentation = "1.11.0" --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b57207a..e294c49c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -487,9 +487,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.7.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8716a166f290ff49dabc18b44aa407cb7c6dbe1aa0971b44b8a24b0ca35aae" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" diff --git a/Cargo.toml b/Cargo.toml index 24a85fda..2915732f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ panic = "abort" codegen-units = 1 [dependencies] -unicode-segmentation = "1.6.0" +unicode-segmentation = "1.11.0" unicode-width = "0.1.8" clap = "2.33.3" shellexpand = "2.0.0" From 551205b963b55a3b06a0c195867ac2975bf67a8c Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 15:56:54 -0400 Subject: [PATCH 14/20] Update unicode-width = "0.1.12" --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e294c49c..9b6b29f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -493,9 +493,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" diff --git a/Cargo.toml b/Cargo.toml index 2915732f..671f6e1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ codegen-units = 1 [dependencies] unicode-segmentation = "1.11.0" -unicode-width = "0.1.8" +unicode-width = "0.1.12" clap = "2.33.3" shellexpand = "2.0.0" ron = "0.6.2" From 1d0f2f8ef40f36bd86f45d977d3afe918a1a55b6 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 16:20:47 -0400 Subject: [PATCH 15/20] Update shellexpand = "3.1.0" --- Cargo.lock | 136 +++++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- 2 files changed, 117 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b6b29f0..66b22fe8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] @@ -92,9 +92,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -153,7 +153,7 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8fed639d60b58d0f53498ab13d26f621fd77569cc6edb031f4cc36a2ad9da0f" dependencies = [ - "dirs-sys", + "dirs-sys 0.3.5", ] [[package]] @@ -163,7 +163,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" dependencies = [ "cfg-if 0.1.10", - "dirs-sys", + "dirs-sys 0.3.5", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys 0.4.1", ] [[package]] @@ -173,10 +182,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" dependencies = [ "libc", - "redox_users", + "redox_users 0.3.5", "winapi", ] +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users 0.4.5", + "windows-sys", +] + [[package]] name = "getrandom" version = "0.1.15" @@ -188,11 +209,22 @@ dependencies = [ "wasi 0.9.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] @@ -209,6 +241,16 @@ version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.5.0", + "libc", +] + [[package]] name = "lock_api" version = "0.4.6" @@ -245,6 +287,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "ox" version = "0.2.7" @@ -286,18 +334,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.7" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -323,11 +371,22 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom", + "getrandom 0.1.15", "redox_syscall 0.1.57", "rust-argon2", ] +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom 0.2.14", + "libredox", + "thiserror", +] + [[package]] name = "regex" version = "1.4.2" @@ -392,16 +451,16 @@ checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.48", ] [[package]] name = "shellexpand" -version = "2.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2b22262a9aaf9464d356f656fea420634f78c881c5eebd5ef5e66d8b9bc603" +checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" dependencies = [ - "dirs", + "dirs 5.0.1", ] [[package]] @@ -457,13 +516,24 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "syn" +version = "2.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "term" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" dependencies = [ - "dirs", + "dirs 2.0.2", "winapi", ] @@ -476,6 +546,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "thread_local" version = "1.0.1" @@ -485,6 +575,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + [[package]] name = "unicode-segmentation" version = "1.11.0" diff --git a/Cargo.toml b/Cargo.toml index 671f6e1c..b37a6132 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ codegen-units = 1 unicode-segmentation = "1.11.0" unicode-width = "0.1.12" clap = "2.33.3" -shellexpand = "2.0.0" +shellexpand = "3.1.0" ron = "0.6.2" serde = "1.0.117" regex = "1.4.2" From 08ae72577a4884059d5945e5fcfe2b2abd7f69de Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 16:23:18 -0400 Subject: [PATCH 16/20] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c281ac6b..ffd60c75 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Rust](https://github.com/prfiredragon/ox/actions/workflows/rust.yml/badge.svg)](https://github.com/prfiredragon/ox/actions/workflows/rust.yml) +[![DevSkim](https://github.com/prfiredragon/ox/actions/workflows/devskim.yml/badge.svg)](https://github.com/prfiredragon/ox/actions/workflows/devskim.yml)

From 2d471c39087a2cc1536d01cd6a141f6bf22f83b2 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 16:37:19 -0400 Subject: [PATCH 17/20] Update term = "0.7.0" --- Cargo.lock | 42 ++++++++++++++++++++++++++++++------------ Cargo.toml | 2 +- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66b22fe8..1e0e7dae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,21 +158,21 @@ dependencies = [ [[package]] name = "dirs" -version = "2.0.2" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "cfg-if 0.1.10", - "dirs-sys 0.3.5", + "dirs-sys 0.4.1", ] [[package]] -name = "dirs" -version = "5.0.1" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "dirs-sys 0.4.1", + "cfg-if 1.0.0", + "dirs-sys-next", ] [[package]] @@ -198,6 +198,17 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users 0.4.5", + "winapi", +] + [[package]] name = "getrandom" version = "0.1.15" @@ -428,6 +439,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "rustversion" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" + [[package]] name = "scopeguard" version = "1.1.0" @@ -460,7 +477,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" dependencies = [ - "dirs 5.0.1", + "dirs", ] [[package]] @@ -529,11 +546,12 @@ dependencies = [ [[package]] name = "term" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" dependencies = [ - "dirs 2.0.2", + "dirs-next", + "rustversion", "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index b37a6132..5ad0e06b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ serde = "1.0.117" regex = "1.4.2" directories = "3.0.1" crossterm = "0.27.0" -term = "0.6.1" +term = "0.7.0" [package.metadata.rpm] package = "ox" From 98433cfb909bc41e1014aa6f7c044af1200443b8 Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 16:47:10 -0400 Subject: [PATCH 18/20] bash file for RRC OS build --- buildrrcos.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 buildrrcos.sh diff --git a/buildrrcos.sh b/buildrrcos.sh new file mode 100644 index 00000000..dfacefcd --- /dev/null +++ b/buildrrcos.sh @@ -0,0 +1,3 @@ +mkdir -pv /system/packages/ox +cargo build --release +cargo install --path . --root=/system/packages/ox From 8333bf08976ed43cd8a9c02c61b5aa8a73f1708d Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 17:21:25 -0400 Subject: [PATCH 19/20] Fix delete on the end of the line --- src/editor.rs | 14 +++++++------- test.txt | 12 ++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 27257050..402297a1 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -346,14 +346,14 @@ impl Editor { KeyBinding::Raw(RawKey::Delete) => { self.doc[self.tab].redo_stack.empty(); self.execute( - /*if current.x == 0 && current.y != 0 { - // Backspace at the start of a line - Event::SpliceUp(current, current) - } else if current.x == 0 { - return; + if current.x == self.doc[self.tab].rows[current.y].length() { + let postosplice = Position { + x: 1, + y: current.y.saturating_add(1), + }; + Event::SpliceUp(postosplice, current) } else { - */ // Backspace in the middle of a line - { + // Delete in the middle of a line let row = self.doc[self.tab].rows[current.y].clone(); let chr = row .ext_chars() diff --git a/test.txt b/test.txt index 61fe7b68..a818b53d 100644 --- a/test.txt +++ b/test.txt @@ -1,3 +1,15 @@ efeerererererregretyer4ty wtywretywtywtywtywtreywtywty wtywtywtyw4teywywtywteywtyty + +dsfsdfl;dgjfnhaldsfhlkawshfgawsiufg +sfgd'lohsw;ldfh'sadfswdfg +asd'fghasdfo'hiahgfihasdfg +ag +afeg +asfg +saf +aefgasfolgjh;dlkofh;oadsugoujha;hfg +gasefsg]afdg]iadfgipohadwfhi\a\gafg\argagawrgr\ +fslgasfljglefsghsfgsfglsgfnijlksg +gajshpdfgaipoefjhpoiaefhgiohawfgoius\ From 4e72be5c6590625aab5e546066cbe3f0ab71eb8b Mon Sep 17 00:00:00 2001 From: Roberto Rodriguez Date: Wed, 1 May 2024 19:35:47 -0400 Subject: [PATCH 20/20] cleanup --- src/editor.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 402297a1..9e35472d 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -357,10 +357,10 @@ impl Editor { let row = self.doc[self.tab].rows[current.y].clone(); let chr = row .ext_chars() - .get(current.x)//.saturating_add(1)) + .get(current.x) .map_or(" ", |chr| *chr); let current = Position { - x: current.x,//.saturating_add(1),//saturating_sub(UnicodeWidthStr::width(chr)), + x: current.x, y: current.y, }; Event::DeletionFw(current, chr.parse().unwrap_or(' '))