Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement match clearing and add a keybinding for it #1

Merged
merged 2 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Key Binds
U,⇞ go up a screen
w toggle line wrap
/ search
c clear search matches
F1 view help
F2 view recently opened files

Expand Down
1 change: 1 addition & 0 deletions les.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ void next_match ();
void prev_match ();
void load_search_history ();
void save_search_history ();
void clear_matches ();

#endif

4 changes: 4 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ char *usage_text () {
" U,⇞ go up a screen\n"
" w toggle line wrap\n"
" / search\n"
" c clear search matches\n"
" F1 view help\n"
" F2 view recently opened files\n";
return str;
Expand Down Expand Up @@ -312,6 +313,9 @@ int read_key (char *buf, int len) {
case '/':
search();
break;
case 'c':
clear_matches();
break;
case -0x40 + 'D':
move_forward(10000);
break;
Expand Down
12 changes: 12 additions & 0 deletions search.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ void save_search_history () {
fclose(fp);
}

void clear_matches () {
tabb->matches = NULL;
tabb->matches_len = 0;
tabb->matches_size = 0;
tabb->current_match = 0;
tabb->highlights = NULL;
tabb->highlights_len = 0;
tabb->highlights_size = 0;
tabb->highlights_processed = 0;
draw_tab();
}

void search2 (char *pattern) {
active_search = 0;
search_version++;
Expand Down