Skip to content

Commit

Permalink
Add U
Browse files Browse the repository at this point in the history
  • Loading branch information
John Baber-Lucero committed Apr 6, 2022
1 parent 9bae9c6 commit e7bdfc9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edhex"
version = "0.4.0"
version = "0.4.1"
authors = ["John Baber-Lucero <[email protected]>"]
license = "GPL-3.0"
description = "Hex editor that works vaguely like ed"
Expand All @@ -11,6 +11,6 @@ edition = "2018"

[dependencies]
ansi_term = "0.12.1"
edhex_core = { path = "../edhex_core", version = "0.7.0" }
edhex_core = { path = "../edhex_core", version = "0.7.1" }
regex = "1.4.5"
clap = "2.27.0"
28 changes: 20 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ S (S)ave state to a file except the bytes you're editing.
t3d Print 0x3d lines of con(t)extual bytes after current line [Default 0]
T3d Print 0x3d lines of con(T)extual bytes before current line [Default 0]
u (u)pdate filename to write to
U Toggle (U)nderlining main line
v Insert a (v)isual break in the display at the current byte.
NOTE: This does not insert a byte in the file. It's just display.
V Remove a (V)isual break if one is at the current byte.
Expand Down Expand Up @@ -114,7 +115,7 @@ impl Command {
let re_search_again = Regex::new(r"^ *(?P<direction>[/?]) *$").unwrap();
let re_search_kill = Regex::new(r"^ */(?P<bytes>[0-9a-fA-F]+)/k *$").unwrap();
let re_search_insert = Regex::new(r"^ */(?P<bytes>[0-9a-fA-F]+)/i *$").unwrap();
let re_single_char_command = Regex::new(r"^ *(?P<command>[hijkmnopqRrsSlLPuvVwx]).*$").unwrap();
let re_single_char_command = Regex::new(r"^ *(?P<command>[hijkmnopqRrsSlLPuUvVwx]).*$").unwrap();
let re_range = Regex::new(r"^ *(?P<begin>[0-9a-fA-F.$]+) *, *(?P<end>[0-9a-fA-F.$]+) *(?P<the_rest>.*) *$").unwrap();
let re_specified_index = Regex::new(r"^ *(?P<index>[0-9A-Fa-f.$]+) *(?P<the_rest>.*) *$").unwrap();
let re_offset_index = Regex::new(r"^ *(?P<sign>[-+])(?P<offset>[0-9A-Fa-f]+) *(?P<the_rest>.*) *$").unwrap();
Expand Down Expand Up @@ -564,7 +565,7 @@ fn minuses(state:&mut State, num_minuses:usize) -> Result<usize, String> {
}
else {
state.index -= num_minuses;
state.print_bytes(true);
state.print_bytes();
Ok(state.index)
}
}
Expand All @@ -585,7 +586,7 @@ fn pluses(state:&mut State, num_pluses:usize) -> Result<usize, String> {
}
else {
state.index += num_pluses;
state.print_bytes(true);
state.print_bytes();
Ok(state.index)
}
},
Expand Down Expand Up @@ -826,7 +827,7 @@ pub fn actual_runtime(filename:&str, pipe_mode:bool, color:bool, readonly:bool,
println!("{}", Color::Yellow.paint("h for help"));
println!("\n{}", state);
println!();
state.print_bytes(true);
state.print_bytes();
}

// TODO Below here should be a function called main_loop()
Expand Down Expand Up @@ -857,7 +858,7 @@ pub fn actual_runtime(filename:&str, pipe_mode:bool, color:bool, readonly:bool,
'g' => {
match ec::move_to(&mut state, command.range.0) {
Ok(_) => {
state.print_bytes(true);
state.print_bytes();
},
Err(error) => {
println!("? ({})", error);
Expand Down Expand Up @@ -934,7 +935,7 @@ pub fn actual_runtime(filename:&str, pipe_mode:bool, color:bool, readonly:bool,
let first_byte_to_show_index =
state.index.saturating_sub(width);
state.index = first_byte_to_show_index;
state.print_bytes(true);
state.print_bytes();
}


Expand All @@ -951,7 +952,7 @@ pub fn actual_runtime(filename:&str, pipe_mode:bool, color:bool, readonly:bool,
state.all_bytes.append(&mut right_half);
state.index = command.range.0;
state.unsaved_changes = true;
state.print_bytes(true);
state.print_bytes();
},


Expand Down Expand Up @@ -994,6 +995,17 @@ pub fn actual_runtime(filename:&str, pipe_mode:bool, color:bool, readonly:bool,
}
},

/* Toggle underlining non-context line */
'U' => {
state.prefs.underline_main_line =
if state.prefs.underline_main_line {
false
}
else {
true
};
}


/* Insert a break in the display at current byte */
'v' => {
Expand Down Expand Up @@ -1077,7 +1089,7 @@ pub fn actual_runtime(filename:&str, pipe_mode:bool, color:bool, readonly:bool,
continue;
};

state.print_bytes(true);
state.print_bytes();
},

/* Quit */
Expand Down

0 comments on commit e7bdfc9

Please sign in to comment.