Skip to content

Commit

Permalink
Merge pull request #114 from Frank-III/request-body-start-end
Browse files Browse the repository at this point in the history
feat: home/end binding for request body edit
  • Loading branch information
Julien-cpsn authored Oct 27, 2024
2 parents a611f67 + eca7f2a commit a90c8b0
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
4 changes: 4 additions & 0 deletions example_resources/key_bindings/default_key_bindings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ delete_forward = "Backspace"

move_cursor_left = "Left"
move_cursor_right = "Right"
move_cursor_line_start = "Home"
move_cursor_line_end = "End"

# Request body
[keybindings.generic.text_inputs.text_area_mode.Custom]
Expand All @@ -48,6 +50,8 @@ move_cursor_up = "Up"
move_cursor_down = "Down"
move_cursor_left = "Left"
move_cursor_right = "Right"
move_cursor_line_start = "Home"
move_cursor_line_end = "End"

# Navigation in tables, popups, up and down in the collections list
[keybindings.generic.navigation]
Expand Down
8 changes: 8 additions & 0 deletions src/app/files/key_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ nest! {

pub move_cursor_left: KeyCombination,
pub move_cursor_right: KeyCombination,
pub move_cursor_line_start: KeyCombination,
pub move_cursor_line_end: KeyCombination,
},

/// Request body
Expand Down Expand Up @@ -149,6 +151,8 @@ pub struct CustomTextArea {
pub move_cursor_down: KeyCombination,
pub move_cursor_left: KeyCombination,
pub move_cursor_right: KeyCombination,
pub move_cursor_line_start: KeyCombination,
pub move_cursor_line_end: KeyCombination,
}

impl Default for KeyBindings {
Expand Down Expand Up @@ -181,6 +185,8 @@ impl Default for KeyBindings {

move_cursor_left: key!(left),
move_cursor_right: key!(right),
move_cursor_line_start: key!(home),
move_cursor_line_end: key!(end),
},
text_area_mode: TextAreaMode::Custom(CustomTextArea::default()),
},
Expand Down Expand Up @@ -268,6 +274,8 @@ impl Default for CustomTextArea {
move_cursor_down: key!(down),
move_cursor_left: key!(left),
move_cursor_right: key!(right),
move_cursor_line_start: key!(home),
move_cursor_line_end: key!(end),
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/tui/app_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ impl AppState {
EditingRequestUrlDeleteCharForward(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.delete_forward], "Delete char forward", Some("Backspace"))),
EditingRequestUrlMoveCursorLeft(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_left], "Move cursor left", Some("Left"))),
EditingRequestUrlMoveCursorRight(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_right], "Move cursor right", Some("Right"))),
EditingRequestUrlMoveCursorLineStart(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_start], "Move cursor line start", Some("Home"))),
EditingRequestUrlMoveCursorLineEnd(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_end], "Move cursor line start", Some("Home"))),
EditingRequestUrlCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
EditingRequestParam => vec![
Expand All @@ -399,6 +401,8 @@ impl AppState {
EditingRequestQueryParamDeleteCharForward(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.delete_forward], "Delete char forward", Some("Backspace"))),
EditingRequestQueryParamMoveCursorLeft(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_left], "Move cursor left", Some("Left"))),
EditingRequestQueryParamMoveCursorRight(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_right], "Move cursor right", Some("Right"))),
EditingRequestQueryParamMoveCursorLineStart(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_start], "Move cursor line start", Some("Home"))),
EditingRequestQueryParamMoveCursorLineEnd(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_end], "Move cursor line start", Some("Home"))),
EditingRequestQueryParamCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
EditingRequestAuthUsername => vec![
Expand All @@ -409,6 +413,8 @@ impl AppState {
EditingRequestAuthUsernameDeleteCharForward(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.delete_forward], "Delete char forward", Some("Backspace"))),
EditingRequestAuthUsernameMoveCursorLeft(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_left], "Move cursor left", Some("Left"))),
EditingRequestAuthUsernameMoveCursorRight(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_right], "Move cursor right", Some("Right"))),
EditingRequestAuthUsernameMoveCursorLineStart(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_start], "Move cursor line start", Some("Home"))),
EditingRequestAuthUsernameMoveCursorLineEnd(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_end], "Move cursor line start", Some("Home"))),
EditingRequestAuthUsernameCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
EditingRequestAuthPassword => vec![
Expand All @@ -419,6 +425,8 @@ impl AppState {
EditingRequestAuthPasswordDeleteCharForward(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.delete_forward], "Delete char forward", Some("Backspace"))),
EditingRequestAuthPasswordMoveCursorLeft(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_left], "Move cursor left", Some("Left"))),
EditingRequestAuthPasswordMoveCursorRight(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_right], "Move cursor right", Some("Right"))),
EditingRequestAuthPasswordMoveCursorLineStart(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_start], "Move cursor line start", Some("Home"))),
EditingRequestAuthPasswordMoveCursorLineEnd(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_end], "Move cursor line start", Some("Home"))),
EditingRequestAuthPasswordCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
EditingRequestAuthBearerToken => vec![
Expand All @@ -429,6 +437,8 @@ impl AppState {
EditingRequestAuthBearerTokenDeleteCharForward(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.delete_forward], "Delete char forward", Some("Backspace"))),
EditingRequestAuthBearerTokenMoveCursorLeft(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_left], "Move cursor left", Some("Left"))),
EditingRequestAuthBearerTokenMoveCursorRight(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_right], "Move cursor right", Some("Right"))),
EditingRequestAuthBearerTokenMoveCursorLineStart(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_start], "Move cursor line start", Some("Home"))),
EditingRequestAuthBearerTokenMoveCursorLineEnd(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_end], "Move cursor line start", Some("Home"))),
EditingRequestAuthBearerTokenCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
EditingRequestHeader => vec![
Expand All @@ -439,6 +449,8 @@ impl AppState {
EditingRequestHeaderDeleteCharForward(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.delete_forward], "Delete char forward", Some("Backspace"))),
EditingRequestHeaderMoveCursorLeft(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_left], "Move cursor left", Some("Left"))),
EditingRequestHeaderMoveCursorRight(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_right], "Move cursor right", Some("Right"))),
EditingRequestHeaderMoveCursorLineStart(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_start], "Move cursor line start", Some("Home"))),
EditingRequestHeaderMoveCursorLineEnd(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_end], "Move cursor line start", Some("Home"))),
EditingRequestHeaderCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
EditingRequestBodyTable => vec![
Expand All @@ -449,6 +461,8 @@ impl AppState {
EditingRequestBodyTableDeleteCharForward(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.delete_forward], "Delete char forward", Some("Backspace"))),
EditingRequestBodyTableMoveCursorLeft(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_left], "Move cursor left", Some("Left"))),
EditingRequestBodyTableMoveCursorRight(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_right], "Move cursor right", Some("Right"))),
EditingRequestBodyTableMoveCursorLineStart(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_start], "Move cursor line start", Some("Home"))),
EditingRequestBodyTableMoveCursorLineEnd(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_end], "Move cursor line start", Some("Home"))),
EditingRequestBodyTableCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
EditingRequestBodyFile => vec![
Expand All @@ -459,6 +473,8 @@ impl AppState {
EditingRequestBodyFileDeleteCharForward(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.delete_forward], "Delete char forward", Some("Backspace"))),
EditingRequestBodyFileMoveCursorLeft(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_left], "Move cursor left", Some("Left"))),
EditingRequestBodyFileMoveCursorRight(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_right], "Move cursor right", Some("Right"))),
EditingRequestBodyFileMoveCursorLineStart(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_start], "Move cursor line start", Some("Home"))),
EditingRequestBodyFileMoveCursorLineEnd(EventKeyBinding::new(vec![key_bindings.generic.text_inputs.text_input.move_cursor_line_end], "Move cursor line start", Some("Home"))),
EditingRequestBodyFileCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
EditingRequestBodyString => match key_bindings.generic.text_inputs.text_area_mode {
Expand All @@ -485,6 +501,8 @@ impl AppState {
EditingRequestBodyStringMoveCursorDown(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_down], "Down", Some("Down"))),
EditingRequestBodyStringMoveCursorLeft(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_left], "Left", Some("Left"))),
EditingRequestBodyStringMoveCursorRight(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_right], "Right", Some("Right"))),
EditingRequestBodyStringMoveCursorLineStart(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_line_start], "Line start", None)),
EditingRequestBodyStringMoveCursorLineEnd(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_line_end], "Line end", None)),
EditingRequestBodyStringCharInput(EventKeyBinding::new(vec![], "Char input", None)),
],
},
Expand Down Expand Up @@ -512,6 +530,8 @@ impl AppState {
EditingPreRequestScriptMoveCursorDown(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_down], "Down", Some("Down"))),
EditingPreRequestScriptMoveCursorLeft(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_left], "Left", Some("Left"))),
EditingPreRequestScriptMoveCursorRight(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_right], "Right", Some("Right"))),
EditingPreRequestScriptMoveCursorLineStart(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_line_start], "Line start", None)),
EditingPreRequestScriptMoveCursorLineEnd(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_line_end], "Line end", None)),
EditingPreRequestScriptCharInput(EventKeyBinding::new(vec![], "Char input", None)),
]
},
Expand Down Expand Up @@ -539,6 +559,8 @@ impl AppState {
EditingPostRequestScriptMoveCursorDown(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_down], "Down", Some("Down"))),
EditingPostRequestScriptMoveCursorLeft(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_left], "Left", Some("Left"))),
EditingPostRequestScriptMoveCursorRight(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_right], "Right", Some("Right"))),
EditingPostRequestScriptMoveCursorLineStart(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_line_start], "Line start", None)),
EditingPostRequestScriptMoveCursorLineEnd(EventKeyBinding::new(vec![text_area_key_bindings.move_cursor_line_end], "Line end", None)),
EditingPostRequestScriptCharInput(EventKeyBinding::new(vec![], "Char input", None)),
]
}
Expand Down
Loading

0 comments on commit a90c8b0

Please sign in to comment.