mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-13 14:45:59 +01:00
Search fix, overworked Makefile
A little fix that solves the forwards, backwards searching problem and an overworked, cleaned up Makefile
This commit is contained in:
parent
864c7dc29d
commit
96b0393531
3 changed files with 24 additions and 10 deletions
7
Makefile
7
Makefile
|
@ -11,15 +11,12 @@ $(TARGET): zathura.c config.h
|
|||
clean:
|
||||
rm -f $(TARGET)
|
||||
|
||||
debug: $(TARGET)
|
||||
debug:
|
||||
gcc $(FLAGS) -Wall -o $(TARGET) $(SOURCE) -g
|
||||
|
||||
valgrind: debug $(TARGET)
|
||||
valgrind: debug
|
||||
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./${TARGET}
|
||||
|
||||
scrollbars: $(TARGET)
|
||||
gcc $(FLAGS) -Wall -o $(TARGET) $(SOURCE) -DSHOW_SCROLLBARS
|
||||
|
||||
install: all
|
||||
@echo installing executeable to /usr/bin
|
||||
@mkdir -p /usr/bin
|
||||
|
|
5
config.h
5
config.h
|
@ -7,6 +7,7 @@ static const int DEFAULT_WIDTH = 800;
|
|||
static const int DEFAULT_HEIGHT = 600;
|
||||
static const char BROWSER[] = "firefox %s";
|
||||
static const char PRINTER[] = "EPSON_AL-CX11_192.168.88.80";
|
||||
|
||||
/* look */
|
||||
static const char font[] = "monospace normal 9";
|
||||
static const char default_bgcolor[] = "#000000";
|
||||
|
@ -29,6 +30,10 @@ static const char completion_hl_bgcolor[] = "#9FBC00";
|
|||
|
||||
static const char search_highlight[] = "#9FBC00";
|
||||
|
||||
/* additional settings */
|
||||
#define SHOW_SCROLLBARS 0
|
||||
#define INCREMENTAL_SEARCH 0
|
||||
|
||||
/* shortcuts */
|
||||
Shortcut shortcuts[] = {
|
||||
// mask, key, function, argument
|
||||
|
|
22
zathura.c
22
zathura.c
|
@ -183,7 +183,7 @@ init()
|
|||
gtk_viewport_set_shadow_type((GtkViewport*) gtk_bin_get_child(GTK_BIN(Zathura.view)), GTK_SHADOW_NONE);
|
||||
g_signal_connect(G_OBJECT(Zathura.view), "key-press-event", G_CALLBACK(cb_view_key_pressed), NULL);
|
||||
|
||||
#ifdef SHOW_SCROLLBARS
|
||||
#if SHOW_SCROLLBARS
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(Zathura.view), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
#else
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(Zathura.view), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
||||
|
@ -396,6 +396,7 @@ draw()
|
|||
cairo_rotate(cairo, Zathura.PDF.rotate * G_PI / 180.0);
|
||||
|
||||
poppler_page_render(Zathura.PDF.page, cairo);
|
||||
|
||||
cairo_restore(cairo);
|
||||
cairo_destroy(cairo);
|
||||
|
||||
|
@ -711,7 +712,7 @@ sc_search(Argument *argument)
|
|||
GList* list;
|
||||
|
||||
if(argument->data)
|
||||
search_item = (char*) argument->data;
|
||||
search_item = g_strdup((char*) argument->data);
|
||||
|
||||
if(!Zathura.PDF.document || !Zathura.PDF.page || !search_item)
|
||||
return;
|
||||
|
@ -722,9 +723,10 @@ sc_search(Argument *argument)
|
|||
if(argument->n)
|
||||
direction = (argument->n == BACKWARD) ? -1 : 1;
|
||||
|
||||
for(page_counter = 0; page_counter < Zathura.PDF.number_of_pages; page_counter++)
|
||||
for(page_counter = 1; page_counter <= Zathura.PDF.number_of_pages; page_counter++)
|
||||
{
|
||||
int next_page = (Zathura.PDF.page_number + page_counter * direction) % Zathura.PDF.number_of_pages;
|
||||
int next_page = (Zathura.PDF.number_of_pages + Zathura.PDF.page_number +
|
||||
page_counter * direction) % Zathura.PDF.number_of_pages;
|
||||
set_page(next_page);
|
||||
|
||||
results = poppler_page_find_text(Zathura.PDF.page, search_item);
|
||||
|
@ -749,6 +751,9 @@ sc_search(Argument *argument)
|
|||
result->y2 = page_height - result->y2;
|
||||
highlight_result(result);
|
||||
}
|
||||
|
||||
if(argument->n == FORWARD || argument->n == BACKWARD)
|
||||
update_status();
|
||||
}
|
||||
else
|
||||
update_notification(search_status, DEFAULT, g_strdup_printf("No match for %s", search_item));
|
||||
|
@ -1254,7 +1259,11 @@ gboolean
|
|||
cb_inputbar_key_released(GtkEntry *entry, GdkEventKey *event, gpointer data)
|
||||
{
|
||||
int length = gtk_entry_get_text_length(entry);
|
||||
|
||||
#if INCREMENTAL_SEARCH
|
||||
char* text = (char*) gtk_entry_get_text(entry);
|
||||
#endif
|
||||
|
||||
Argument argument;
|
||||
|
||||
if(!length)
|
||||
|
@ -1262,14 +1271,17 @@ cb_inputbar_key_released(GtkEntry *entry, GdkEventKey *event, gpointer data)
|
|||
argument.n = HIDE;
|
||||
complete(&argument);
|
||||
}
|
||||
|
||||
#if INCREMENTAL_SEARCH
|
||||
else if(length > 1 && text[0] == '/')
|
||||
{
|
||||
Argument argument;
|
||||
argument.data = (char*) text + 1;
|
||||
sc_search(&argument);
|
||||
//sc_search(&argument);
|
||||
gtk_widget_grab_focus(GTK_WIDGET(Zathura.inputbar));
|
||||
gtk_editable_set_position(GTK_EDITABLE(Zathura.inputbar), -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue