Skip to content

Commit fb35a34

Browse files
committed
Refactor
1 parent 888aae2 commit fb35a34

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

zathura/synctex.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#ifdef WITH_SYNCTEX
1919
// Create scanner from given PDF file name.
2020
// Returns zathura->synctex.scanner. (May be NULL on error.)
21-
synctex_scanner_p synctex_make_scanner(zathura_t *zathura, const char* pdf_filename) {
21+
synctex_scanner_p synctex_make_scanner(zathura_t* zathura, const char* pdf_filename) {
2222
if (zathura->synctex.scanner) {
2323
return zathura->synctex.scanner;
2424
}
@@ -40,8 +40,8 @@ synctex_scanner_p synctex_make_scanner(zathura_t *zathura, const char* pdf_filen
4040
return scanner;
4141
}
4242

43-
bool synctex_get_input_line_column(zathura_t* zathura, const char* filename, unsigned int page, int x, int y, char** input_file,
44-
unsigned int* line, unsigned int* column) {
43+
bool synctex_get_input_line_column(zathura_t* zathura, const char* filename, unsigned int page, int x, int y,
44+
char** input_file, unsigned int* line, unsigned int* column) {
4545
if (filename == NULL) {
4646
return false;
4747
}
@@ -52,7 +52,6 @@ bool synctex_get_input_line_column(zathura_t* zathura, const char* filename, uns
5252
}
5353

5454
bool ret = false;
55-
5655
if (synctex_edit_query(scanner, page + 1u, x, y) > 0) {
5756
/* Assume that a backward search returns at most one result. */
5857
synctex_node_p node = synctex_scanner_next_result(scanner);
@@ -93,8 +92,8 @@ void synctex_edit(zathura_t* zathura, const char* editor, zathura_page_t* page,
9392
unsigned int column = 0;
9493
char* input_file = NULL;
9594

96-
if (synctex_get_input_line_column(zathura, filename, zathura_page_get_index(page), x, y, &input_file, &line, &column) ==
97-
true &&
95+
if (synctex_get_input_line_column(zathura, filename, zathura_page_get_index(page), x, y, &input_file, &line,
96+
&column) == true &&
9897
input_file != NULL) {
9998
char* linestr = g_strdup_printf("%d", line);
10099
char* columnstr = g_strdup_printf("%d", column);
@@ -138,8 +137,9 @@ void synctex_edit(zathura_t* zathura, const char* editor, zathura_page_t* page,
138137
}
139138
}
140139

141-
girara_list_t* synctex_rectangles_from_position(zathura_t* zathura, const char* filename, const char* input_file, int line, int column,
142-
unsigned int* page, girara_list_t** secondary_rects) {
140+
girara_list_t* synctex_rectangles_from_position(zathura_t* zathura, const char* filename, const char* input_file,
141+
int line, int column, unsigned int* page,
142+
girara_list_t** secondary_rects) {
143143
if (filename == NULL || input_file == NULL || page == NULL) {
144144
return NULL;
145145
}
@@ -207,17 +207,18 @@ girara_list_t* synctex_rectangles_from_position(zathura_t* zathura, const char*
207207
return hitlist_flat;
208208
}
209209
#else
210-
bool synctex_get_input_line_column(zathura_t* UNUSED(zathura), const char* UNUSED(filename), unsigned int UNUSED(page), int UNUSED(x),
211-
int UNUSED(y), char** UNUSED(input_file), unsigned int* UNUSED(line),
210+
bool synctex_get_input_line_column(zathura_t* UNUSED(zathura), const char* UNUSED(filename), unsigned int UNUSED(page),
211+
int UNUSED(x), int UNUSED(y), char** UNUSED(input_file), unsigned int* UNUSED(line),
212212
unsigned int* UNUSED(column)) {
213213
return false;
214214
}
215215

216-
void synctex_edit(zathura_t* UNUSED(zathura), const char* UNUSED(editor), zathura_page_t* UNUSED(page), int UNUSED(x), int UNUSED(y)) {}
216+
void synctex_edit(zathura_t* UNUSED(zathura), const char* UNUSED(editor), zathura_page_t* UNUSED(page), int UNUSED(x),
217+
int UNUSED(y)) {}
217218

218-
girara_list_t* synctex_rectangles_from_position(zathura_t* UNUSED(zathura), const char* UNUSED(filename), const char* UNUSED(input_file),
219-
int UNUSED(line), int UNUSED(column), unsigned int* UNUSED(page),
220-
girara_list_t** UNUSED(secondary_rects)) {
219+
girara_list_t* synctex_rectangles_from_position(zathura_t* UNUSED(zathura), const char* UNUSED(filename),
220+
const char* UNUSED(input_file), int UNUSED(line), int UNUSED(column),
221+
unsigned int* UNUSED(page), girara_list_t** UNUSED(secondary_rects)) {
221222
return NULL;
222223
}
223224
#endif
@@ -338,8 +339,8 @@ bool synctex_view(zathura_t* zathura, const char* input_file, unsigned int line,
338339

339340
unsigned int page = 0;
340341
girara_list_t* secondary_rects = NULL;
341-
girara_list_t* rectangles = synctex_rectangles_from_position(zathura, zathura_document_get_path(zathura->document), input_file,
342-
line, column, &page, &secondary_rects);
342+
girara_list_t* rectangles = synctex_rectangles_from_position(zathura, zathura_document_get_path(zathura->document),
343+
input_file, line, column, &page, &secondary_rects);
343344

344345
if (rectangles == NULL) {
345346
return false;

zathura/zathura.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,14 @@ bool document_close(zathura_t* zathura, bool keep_monitor) {
14911491
document_predecessor_free(zathura);
14921492
}
14931493

1494+
#ifdef WITH_SYNCTEX
1495+
/* invalidate synctex scanner */
1496+
if (zathura->synctex.scanner != NULL) {
1497+
synctex_scanner_free(zathura->synctex.scanner);
1498+
zathura->synctex.scanner = NULL;
1499+
}
1500+
#endif
1501+
14941502
/* remove widgets */
14951503
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, NULL);
14961504

@@ -1535,14 +1543,6 @@ bool document_close(zathura_t* zathura, bool keep_monitor) {
15351543
/* update title */
15361544
girara_set_window_title(zathura->ui.session, "zathura");
15371545

1538-
#ifdef WITH_SYNCTEX
1539-
/* invalidate synctex scanner */
1540-
if (zathura->synctex.scanner) {
1541-
synctex_scanner_free(zathura->synctex.scanner);
1542-
zathura->synctex.scanner = NULL;
1543-
}
1544-
#endif
1545-
15461546
return true;
15471547
}
15481548

0 commit comments

Comments
 (0)