Skip to content

Commit

Permalink
Merge pull request #1 from resolritter/master
Browse files Browse the repository at this point in the history
Implement match clearing and add a keybinding for it
  • Loading branch information
zorgnax authored Sep 30, 2020
2 parents 82a7023 + 1e48573 commit a3841fd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
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

0 comments on commit a3841fd

Please sign in to comment.