aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-08 17:27:25 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-08 17:27:25 +0200
commite7b6ac1574ba4dad280e6a45beb52dac4e3ea2e9 (patch)
treec77ced81181dcb972afc2b52e7425ddc29228319 /vis.c
parent403ee5284a70f778b379041c169f72a7586c59ee (diff)
downloadvis-e7b6ac1574ba4dad280e6a45beb52dac4e3ea2e9.tar.gz
vis-e7b6ac1574ba4dad280e6a45beb52dac4e3ea2e9.tar.xz
Hook up search as a movement
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/vis.c b/vis.c
index 8487a69..ec5bf6d 100644
--- a/vis.c
+++ b/vis.c
@@ -9,8 +9,6 @@ static void vis_window_free(VisWin *win);
static void vis_window_split_internal(Vis *vis, const char *filename);
static void vis_windows_invalidate(Vis *vis, size_t start, size_t end);
static void vis_window_draw(VisWin *win);
-static void vis_search_forward(Vis *vis, Regex *regex);
-static void vis_search_backward(Vis *vis, Regex *regex);
static void vis_windows_arrange_horizontal(Vis *vis);
static void vis_windows_arrange_vertical(Vis *vis);
@@ -53,55 +51,6 @@ void vis_statusbar_set(Vis *vis, vis_statusbar_t statusbar) {
vis->statusbar = statusbar;
}
-static void vis_search_forward(Vis *vis, Regex *regex) {
- VisWin *win = vis->win;
- int pos = window_cursor_get(win->win) + 1;
- int end = text_size(win->text);
- RegexMatch match[1];
- bool found = false;
- if (text_search_forward(win->text, pos, end - pos, regex, 1, match, 0)) {
- pos = 0;
- end = window_cursor_get(win->win);
- if (!text_search_forward(win->text, pos, end, regex, 1, match, 0))
- found = true;
- } else {
- found = true;
- }
- if (found)
- window_cursor_to(win->win, match[0].start);
-}
-
-static void vis_search_backward(Vis *vis, Regex *regex) {
- VisWin *win = vis->win;
- int pos = 0;
- int end = window_cursor_get(win->win);
- RegexMatch match[1];
- bool found = false;
- if (text_search_backward(win->text, pos, end, regex, 1, match, 0)) {
- pos = window_cursor_get(win->win) + 1;
- end = text_size(win->text);
- if (!text_search_backward(win->text, pos, end - pos, regex, 1, match, 0))
- found = true;
- } else {
- found = true;
- }
- if (found)
- window_cursor_to(win->win, match[0].start);
-}
-
-void vis_search(Vis *vis, const char *s, int direction) {
- Regex *regex = text_regex_new();
- if (!regex)
- return;
- if (!text_regex_compile(regex, s, REG_EXTENDED)) {
- if (direction >= 0)
- vis_search_forward(vis, regex);
- else
- vis_search_backward(vis, regex);
- }
- text_regex_free(regex);
-}
-
void vis_snapshot(Vis *vis) {
text_snapshot(vis->win->text);
}