Skip to content

Commit 28b4e22

Browse files
author
saying121
committed
BREAKING CHANGE: Remove submit_code and test_code keymap, use replace by toggle.
1 parent 1a84e94 commit 28b4e22

File tree

15 files changed

+203
-147
lines changed

15 files changed

+203
-147
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ All notable changes to this project will be documented in this file.
66
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
77
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [Unreleased]
10+
11+
### Added
12+
13+
- Use `toggle` trigger submit and test code.
14+
15+
### Changed
16+
17+
- Remove `submit_code` and `test_code` keymap, use replace by `toggle`.
18+
919
## [0.8.1] - 2024-04-28
1020

1121
### Fixed

completions/_lcode

+2-2
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ esac
337337
_lcode_commands() {
338338
local commands; commands=(
339339
'edit:Edit \`code\` or \`test cases\`, \[ alias\: e \]' \
340-
'fzy:Interact select a question (fuzzy search), default view detail \[ alias\: f \]' \
340+
'fzy:Interact select a question (fuzzy search), \[ alias\: f \]' \
341341
'detail:View a question detail \[ alias\: D \]' \
342342
'sync:Syncanhronize leetcode info \[ alias\: S \]' \
343343
'test:Test your code \[ alias\: t \]' \
@@ -493,7 +493,7 @@ _lcode__fzy__help__help_commands() {
493493
_lcode__help_commands() {
494494
local commands; commands=(
495495
'edit:Edit \`code\` or \`test cases\`, \[ alias\: e \]' \
496-
'fzy:Interact select a question (fuzzy search), default view detail \[ alias\: f \]' \
496+
'fzy:Interact select a question (fuzzy search), \[ alias\: f \]' \
497497
'detail:View a question detail \[ alias\: D \]' \
498498
'sync:Syncanhronize leetcode info \[ alias\: S \]' \
499499
'test:Test your code \[ alias\: t \]' \

completions/lcode.bash

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ _lcode() {
191191
return 0
192192
;;
193193
lcode__edit)
194-
opts="-h --help <INPUT> code test help"
194+
opts="-h --help <ID> code test help"
195195
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
196196
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
197197
return 0
@@ -205,7 +205,7 @@ _lcode() {
205205
return 0
206206
;;
207207
lcode__edit__code)
208-
opts="-h --help <INPUT>"
208+
opts="-h --help <ID>"
209209
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
210210
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
211211
return 0
@@ -275,7 +275,7 @@ _lcode() {
275275
return 0
276276
;;
277277
lcode__edit__test)
278-
opts="-h --help <INPUT>"
278+
opts="-h --help <ID>"
279279
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
280280
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
281281
return 0

completions/lcode.fish

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
complete -c lcode -n "__fish_use_subcommand" -l generate -r -f -a "{bash '',elvish '',fish '',powershell '',zsh ''}"
22
complete -c lcode -n "__fish_use_subcommand" -s h -l help -d 'Print help'
33
complete -c lcode -n "__fish_use_subcommand" -s V -l version -d 'Print version'
4-
complete -c lcode -n "__fish_use_subcommand" -f -a "edit" -d 'Edit `code` or `test cases`, default edit `code` [ alias: e ]'
5-
complete -c lcode -n "__fish_use_subcommand" -f -a "fzy" -d 'Interact select a question (fuzzy search), default view detail [ alias: f ]'
4+
complete -c lcode -n "__fish_use_subcommand" -f -a "edit" -d 'Edit `code` or `test cases`, [ alias: e ]'
5+
complete -c lcode -n "__fish_use_subcommand" -f -a "fzy" -d 'Interact select a question (fuzzy search), [ alias: f ]'
66
complete -c lcode -n "__fish_use_subcommand" -f -a "detail" -d 'View a question detail [ alias: D ]'
77
complete -c lcode -n "__fish_use_subcommand" -f -a "sync" -d 'Syncanhronize leetcode info [ alias: S ]'
88
complete -c lcode -n "__fish_use_subcommand" -f -a "test" -d 'Test your code [ alias: t ]'
@@ -24,13 +24,13 @@ complete -c lcode -n "__fish_seen_subcommand_from edit; and __fish_seen_subcomma
2424
complete -c lcode -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from code; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "test" -d 'Edit test case'
2525
complete -c lcode -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from code; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
2626
complete -c lcode -n "__fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -s h -l help -d 'Print help'
27-
complete -c lcode -n "__fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -f -a "detail" -d 'View detail'
27+
complete -c lcode -n "__fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -f -a "detail" -d 'View detail(default)'
2828
complete -c lcode -n "__fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -f -a "edit" -d 'Edit code'
2929
complete -c lcode -n "__fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
3030
complete -c lcode -n "__fish_seen_subcommand_from fzy; and __fish_seen_subcommand_from detail" -s f -l force -d 'Force update question\'s information'
3131
complete -c lcode -n "__fish_seen_subcommand_from fzy; and __fish_seen_subcommand_from detail" -s h -l help -d 'Print help'
3232
complete -c lcode -n "__fish_seen_subcommand_from fzy; and __fish_seen_subcommand_from edit" -s h -l help -d 'Print help'
33-
complete -c lcode -n "__fish_seen_subcommand_from fzy; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -f -a "detail" -d 'View detail'
33+
complete -c lcode -n "__fish_seen_subcommand_from fzy; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -f -a "detail" -d 'View detail(default)'
3434
complete -c lcode -n "__fish_seen_subcommand_from fzy; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -f -a "edit" -d 'Edit code'
3535
complete -c lcode -n "__fish_seen_subcommand_from fzy; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
3636
complete -c lcode -n "__fish_seen_subcommand_from detail" -s f -l force -d 'Force update question\'s information'
@@ -40,14 +40,14 @@ complete -c lcode -n "__fish_seen_subcommand_from sync" -s h -l help -d 'Print h
4040
complete -c lcode -n "__fish_seen_subcommand_from test" -s h -l help -d 'Print help'
4141
complete -c lcode -n "__fish_seen_subcommand_from submit" -s h -l help -d 'Print help'
4242
complete -c lcode -n "__fish_seen_subcommand_from sublist" -s h -l help -d 'Print help'
43-
complete -c lcode -n "__fish_seen_subcommand_from gencon" -s c -l cn
43+
complete -c lcode -n "__fish_seen_subcommand_from gencon" -s c -l cn -d 'Generate cn config'
4444
complete -c lcode -n "__fish_seen_subcommand_from gencon" -s h -l help -d 'Print help'
4545
complete -c lcode -n "__fish_seen_subcommand_from tui" -s h -l help -d 'Print help'
4646
complete -c lcode -n "__fish_seen_subcommand_from config" -s h -l help -d 'Print help'
4747
complete -c lcode -n "__fish_seen_subcommand_from log" -s h -l help -d 'Print help'
4848
complete -c lcode -n "__fish_seen_subcommand_from star" -s h -l help -d 'Print help'
49-
complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from sync; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from submit; and not __fish_seen_subcommand_from sublist; and not __fish_seen_subcommand_from gencon; and not __fish_seen_subcommand_from tui; and not __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from log; and not __fish_seen_subcommand_from star; and not __fish_seen_subcommand_from help" -f -a "edit" -d 'Edit `code` or `test cases`, default edit `code` [ alias: e ]'
50-
complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from sync; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from submit; and not __fish_seen_subcommand_from sublist; and not __fish_seen_subcommand_from gencon; and not __fish_seen_subcommand_from tui; and not __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from log; and not __fish_seen_subcommand_from star; and not __fish_seen_subcommand_from help" -f -a "fzy" -d 'Interact select a question (fuzzy search), default view detail [ alias: f ]'
49+
complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from sync; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from submit; and not __fish_seen_subcommand_from sublist; and not __fish_seen_subcommand_from gencon; and not __fish_seen_subcommand_from tui; and not __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from log; and not __fish_seen_subcommand_from star; and not __fish_seen_subcommand_from help" -f -a "edit" -d 'Edit `code` or `test cases`, [ alias: e ]'
50+
complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from sync; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from submit; and not __fish_seen_subcommand_from sublist; and not __fish_seen_subcommand_from gencon; and not __fish_seen_subcommand_from tui; and not __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from log; and not __fish_seen_subcommand_from star; and not __fish_seen_subcommand_from help" -f -a "fzy" -d 'Interact select a question (fuzzy search), [ alias: f ]'
5151
complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from sync; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from submit; and not __fish_seen_subcommand_from sublist; and not __fish_seen_subcommand_from gencon; and not __fish_seen_subcommand_from tui; and not __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from log; and not __fish_seen_subcommand_from star; and not __fish_seen_subcommand_from help" -f -a "detail" -d 'View a question detail [ alias: D ]'
5252
complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from sync; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from submit; and not __fish_seen_subcommand_from sublist; and not __fish_seen_subcommand_from gencon; and not __fish_seen_subcommand_from tui; and not __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from log; and not __fish_seen_subcommand_from star; and not __fish_seen_subcommand_from help" -f -a "sync" -d 'Syncanhronize leetcode info [ alias: S ]'
5353
complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from sync; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from submit; and not __fish_seen_subcommand_from sublist; and not __fish_seen_subcommand_from gencon; and not __fish_seen_subcommand_from tui; and not __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from log; and not __fish_seen_subcommand_from star; and not __fish_seen_subcommand_from help" -f -a "test" -d 'Test your code [ alias: t ]'
@@ -61,5 +61,5 @@ complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subc
6161
complete -c lcode -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from sync; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from submit; and not __fish_seen_subcommand_from sublist; and not __fish_seen_subcommand_from gencon; and not __fish_seen_subcommand_from tui; and not __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from log; and not __fish_seen_subcommand_from star; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
6262
complete -c lcode -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from code; and not __fish_seen_subcommand_from test" -f -a "code" -d 'Edit code(default)'
6363
complete -c lcode -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from code; and not __fish_seen_subcommand_from test" -f -a "test" -d 'Edit test case'
64-
complete -c lcode -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit" -f -a "detail" -d 'View detail'
64+
complete -c lcode -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit" -f -a "detail" -d 'View detail(default)'
6565
complete -c lcode -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from fzy; and not __fish_seen_subcommand_from detail; and not __fish_seen_subcommand_from edit" -f -a "edit" -d 'Edit code'

crates/lcode-config/src/keymap.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ pub const TOGGLE_SUBMIT_RES: &str = "toggle_submit_res";
3030
pub const TOGGLE_TEST_RES: &str = "toggle_test_res";
3131
pub const TOGGLE_MENU: &str = "toggle_menu";
3232

33-
pub const TEST_CODE: &str = "test_code";
34-
pub const SUBMIT_CODE: &str = "submit_code";
3533
pub const RE_QS_DETAIL: &str = "re_get_qs";
3634
pub const NEXT_TAB: &str = "next_tab";
3735
pub const PREV_TAB: &str = "prev_tab";
@@ -216,16 +214,6 @@ impl Default for TuiKeyMap {
216214
desc: "re get question detail (reference tab0/select cursor question info)"
217215
.to_owned(),
218216
},
219-
KeyMap {
220-
keys: Keys(vec![Key::new(SHIFT, KeyCode::Char('S'))]),
221-
action: SUBMIT_CODE.to_owned(),
222-
desc: "submit this question code to leetcode (in edit show menu)".to_owned(),
223-
},
224-
KeyMap {
225-
keys: Keys(vec![Key::new(SHIFT, KeyCode::Char('T'))]),
226-
action: TEST_CODE.to_owned(),
227-
desc: "test this question code to leetcode (in edit show menu)".to_owned(),
228-
},
229217
KeyMap {
230218
keys: Keys(vec![Key::new(CTRL, KeyCode::Char('t'))]),
231219
action: TOGGLE_TEST_RES.to_owned(),
@@ -239,7 +227,9 @@ impl Default for TuiKeyMap {
239227
KeyMap {
240228
keys: Keys(vec![Key::new(NO_CONTROL, KeyCode::Enter)]),
241229
action: TOGGLE_CURSOR.to_owned(),
242-
desc: "toggle cursor item(add or rm topic_tags, or goto tab1/edit)".to_owned(),
230+
desc: "trigger cursor item, in edit pop menu will active button (add or rm \
231+
topic_tags, or goto tab1/edit)"
232+
.to_owned(),
243233
},
244234
]);
245235

crates/lcode/src/app/dispatch/handle_key.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ impl<'app_lf> App<'app_lf> {
9797
RIGHT => self.edit.horizontal_scroll_l(),
9898
TOP => self.edit.vertical_scroll_gg(),
9999
BOTTOM => self.edit.vertical_scroll_G(),
100-
HEAD => self.edit.pop_head(),
100+
HEAD => self.edit.goto_pop_head(),
101101
EDIT_IN_TUI => self.edit.start_edit_tui(),
102102
EDIT_CODE_EDITOR => self
103103
.edit_tab_edit_with_editor()
104104
.await
105105
.is_ok(),
106-
SUBMIT_CODE if self.edit.show_pop_menu => self.submit_code(),
107-
TEST_CODE if self.edit.show_pop_menu => self.test_code(),
106+
107+
TOGGLE_CURSOR if self.edit.show_pop_menu => self.menu_button_trig(),
108+
108109
TOGGLE_MENU => self.edit.toggle_menu(),
109110
TOGGLE_SUBMIT_RES => self.edit.toggle_submit_res(),
110111
TOGGLE_TEST_RES => self.edit.toggle_test_res(),

0 commit comments

Comments
 (0)