Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Marius
zathura
Commits
2f53f09e
Commit
2f53f09e
authored
Jun 24, 2014
by
Sebastian Ramacher
Browse files
Merge branch 'develop' of pwmt.org:zathura into develop
parents
0b966dbe
3d96d440
Changes
16
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
2f53f09e
...
...
@@ -4,8 +4,8 @@ include config.mk
include
colors.mk
include
common.mk
OSOURCE
=
$(
filter-out
css-definitions.c,
$(
filter-out
dbus-interface-definitions.c,
$(
wildcard
*
.c
)))
HEADER
=
$(
wildcard
*
.h
)
OSOURCE
=
$(
filter-out
css-definitions.c,
$(
filter-out
dbus-interface-definitions.c,
$(
wildcard
*
.c
)))
$(
wildcard
synctex/
*
.c
)
HEADER
=
$(
wildcard
*
.h
)
$(
wildcard
synctex/
*
.h
)
HEADERINST
=
version.h document.h macros.h page.h types.h plugin-api.h links.h
ifneq
(${WITH_SQLITE},0)
...
...
@@ -36,6 +36,13 @@ endif
ifeq
(,$(findstring -DLOCALEDIR,${CPPFLAGS}))
CPPFLAGS
+=
-DLOCALEDIR
=
\"
${LOCALEDIR}
\"
endif
ifeq
(,$(findstring -Isynctex,${CPPFLAGS}))
CPPFLAGS
+=
-Isynctex
endif
ifeq
(,$(findstring -DSYNCTEX_VERBOSE=0,${CPPFLAGS}))
CPPFLAGS
+=
-DSYNCTEX_VERBOSE
=
0
endif
OBJECTS
=
$(
patsubst
%.c, %.o,
$(SOURCE)
)
dbus-interface-definitions.o css-definitions.o
DOBJECTS
=
$(
patsubst
%.o, %.do,
$(OBJECTS)
)
...
...
@@ -83,7 +90,7 @@ css-definitions.c: data/zathura.css_t
%.o
:
%.c
$(
call
colorecho,CC,
$<
)
$(QUIET)
mkdir
-p
.depend
$(QUIET)
mkdir
-p
$(
shell
dirname
.depend/
$@
.dep
)
$(QUIET)${CC}
-c
${CPPFLAGS}
${CFLAGS}
-o
$@
$<
-MMD
-MF
.depend/
$@
.dep
%.do
:
%.c
...
...
adjustment.c
View file @
2f53f09e
...
...
@@ -63,9 +63,17 @@ position_to_page_number(zathura_document_t* document, double pos_x,
unsigned
int
c0
=
zathura_document_get_first_page_column
(
document
);
unsigned
int
npag
=
zathura_document_get_number_of_pages
(
document
);
unsigned
int
ncol
=
zathura_document_get_pages_per_row
(
document
);
unsigned
int
nrow
=
(
npag
+
c0
-
1
+
ncol
-
1
)
/
ncol
;
/* number of rows */
unsigned
int
nrow
=
0
;
unsigned
int
pad
=
zathura_document_get_page_padding
(
document
);
if
(
c0
==
1
)
{
/* There is no offset, so this is easy. */
nrow
=
(
npag
+
ncol
-
1
)
/
ncol
;
}
else
{
/* If there is a offset, we handle the first row extra. */
nrow
=
1
+
(
npag
-
(
ncol
-
c0
-
1
)
+
(
ncol
-
1
))
/
ncol
;
}
unsigned
int
col
=
floor
(
pos_x
*
(
double
)
doc_width
/
(
double
)(
cell_width
+
pad
));
unsigned
int
row
=
floor
(
pos_y
*
(
double
)
doc_height
/
(
double
)(
cell_height
+
pad
));
...
...
@@ -73,7 +81,7 @@ position_to_page_number(zathura_document_t* document, double pos_x,
if
(
page
<
c0
-
1
)
{
return
0
;
}
else
{
return
page
-
(
c0
-
1
);
return
MIN
(
page
-
(
c0
-
1
),
npag
-
1
);
}
}
...
...
callbacks.c
View file @
2f53f09e
...
...
@@ -137,60 +137,54 @@ cb_view_vadjustment_value_changed(GtkAdjustment* adjustment, gpointer data)
statusbar_page_number_update
(
zathura
);
}
void
cb_view_hadjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
static
void
cb_view_adjustment_changed
(
GtkAdjustment
*
adjustment
,
zathura_t
*
zathura
,
bool
width
)
{
zathura_t
*
zathura
=
data
;
g_return_if_fail
(
zathura
!=
NULL
);
zathura_adjust_mode_t
adjust_mode
=
zathura_document_get_adjust_mode
(
zathura
->
document
);
/* Do nothing in index mode */
if
(
girara_mode_get
(
zathura
->
ui
.
session
)
==
zathura
->
modes
.
index
)
{
return
;
}
/* Don't scroll we're focusing the inputbar. */
const
zathura_adjust_mode_t
adjust_mode
=
zathura_document_get_adjust_mode
(
zathura
->
document
);
/* Don't scroll, we're focusing the inputbar. */
if
(
adjust_mode
==
ZATHURA_ADJUST_INPUTBAR
)
{
return
;
}
/* save the viewport size */
unsigned
int
view_width
=
(
unsigned
int
)
floor
(
gtk_adjustment_get_page_size
(
adjustment
));
zathura_document_set_viewport_width
(
zathura
->
document
,
view_width
);
/* Save the viewport size */
unsigned
int
size
=
(
unsigned
int
)
floor
(
gtk_adjustment_get_page_size
(
adjustment
));
if
(
width
==
true
)
{
zathura_document_set_viewport_width
(
zathura
->
document
,
size
);
}
else
{
zathura_document_set_viewport_height
(
zathura
->
document
,
size
);
}
/* reset the adjustment, in case bounds have changed */
double
ratio
=
zathura_document_get_position_x
(
zathura
->
document
);
const
double
ratio
=
width
==
true
?
zathura_document_get_position_x
(
zathura
->
document
)
:
zathura_document_get_position_x
(
zathura
->
document
);
zathura_adjustment_set_value_from_ratio
(
adjustment
,
ratio
);
}
void
cb_view_
v
adjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
cb_view_
h
adjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
zathura_t
*
zathura
=
data
;
g_return_if_fail
(
zathura
!=
NULL
);
zathura_adjust_mode_t
adjust_mode
=
zathura_document_get_adjust_mode
(
zathura
->
document
);
/* Do nothing in index mode */
if
(
girara_mode_get
(
zathura
->
ui
.
session
)
==
zathura
->
modes
.
index
)
{
return
;
}
/* Don't scroll we're focusing the inputbar. */
if
(
adjust_mode
==
ZATHURA_ADJUST_INPUTBAR
)
{
return
;
}
cb_view_adjustment_changed
(
adjustment
,
zathura
,
true
);
}
/* save the viewport size */
unsigned
int
view_height
=
(
unsigned
int
)
floor
(
gtk_adjustment_get_page_size
(
adjustment
));
zathura_document_set_viewport_height
(
zathura
->
document
,
view_height
);
void
cb_view_vadjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
zathura_t
*
zathura
=
data
;
g_return_if_fail
(
zathura
!=
NULL
);
/* reset the adjustment, in case bounds have changed */
double
ratio
=
zathura_document_get_position_y
(
zathura
->
document
);
zathura_adjustment_set_value_from_ratio
(
adjustment
,
ratio
);
cb_view_adjustment_changed
(
adjustment
,
zathura
,
false
);
}
void
...
...
@@ -233,7 +227,7 @@ cb_page_layout_value_changed(girara_session_t* session, const char* name, girara
if
(
pages_per_row
==
0
)
{
pages_per_row
=
1
;
girara_setting_set
(
session
,
name
,
&
pages_per_row
);
girara_notify
(
session
,
GIRARA_WARNING
,
_
(
"'%s' must not be 0. Set to 1.
.
"
),
name
);
girara_notify
(
session
,
GIRARA_WARNING
,
_
(
"'%s' must not be 0. Set to 1."
),
name
);
return
;
}
}
...
...
config.mk
View file @
2f53f09e
...
...
@@ -77,8 +77,11 @@ MAGIC_INC ?=
MAGIC_LIB
?=
-lmagic
endif
INCS
=
${GIRARA_INC}
${GTK_INC}
${GTHREAD_INC}
${GMODULE_INC}
${GLIB_INC}
LIBS
=
${GIRARA_LIB}
${GTK_LIB}
${GTHREAD_LIB}
${GMODULE_LIB}
${GLIB_LIB}
-lpthread
-lm
ZLIB_INC
?=
$(
shell
pkg-config
--cflags
zlib
)
ZLIB_LIB
?=
$(
shell
pkg-config
--libs
zlib
)
INCS
=
${GIRARA_INC}
${GTK_INC}
${GTHREAD_INC}
${GMODULE_INC}
${GLIB_INC}
$(ZLIB_INC)
LIBS
=
${GIRARA_LIB}
${GTK_LIB}
${GTHREAD_LIB}
${GMODULE_LIB}
${GLIB_LIB}
$(ZLIB_LIB)
-lpthread
-lm
# flags
CFLAGS
+=
-std
=
c99
-pedantic
-Wall
-Wno-format-zero-length
-Wextra
$(INCS)
...
...
dbus-interface.c
View file @
2f53f09e
...
...
@@ -545,17 +545,17 @@ zathura_dbus_goto_page_and_highlight(const char* filename, unsigned int page,
}
bool
zathura_dbus_synctex_position
(
const
char
*
filename
,
const
char
*
position
,
pid_t
hint
)
zathura_dbus_synctex_position
(
const
char
*
filename
,
const
char
*
input_file
,
int
line
,
int
column
,
pid_t
hint
)
{
if
(
filename
==
NULL
||
position
==
NULL
)
{
if
(
filename
==
NULL
||
input_file
==
NULL
)
{
return
false
;
}
unsigned
int
page
=
0
;
girara_list_t
*
secondary_rects
=
NULL
;
girara_list_t
*
rectangles
=
synctex_rectangles_from_position
(
filename
,
positio
n
,
&
page
,
&
secondary_rects
);
filename
,
input_file
,
line
,
colum
n
,
&
page
,
&
secondary_rects
);
if
(
rectangles
==
NULL
)
{
return
false
;
}
...
...
dbus-interface.h
View file @
2f53f09e
...
...
@@ -57,7 +57,7 @@ bool zathura_dbus_goto_page_and_highlight(const char* filename,
unsigned
int
page
,
girara_list_t
*
rectangles
,
girara_list_t
*
secondary_rects
,
pid_t
pidhint
);
bool
zathura_dbus_synctex_position
(
const
char
*
filename
,
const
char
*
position
,
pid_t
pid
hint
);
bool
zathura_dbus_synctex_position
(
const
char
*
filename
,
const
char
*
input_file
,
int
line
,
int
column
,
pid_t
hint
);
#endif
main.c
View file @
2f53f09e
...
...
@@ -106,11 +106,25 @@ main(int argc, char* argv[])
return
-
1
;
}
if
(
zathura_dbus_synctex_position
(
real_path
,
synctex_fwd
,
synctex_pid
)
==
true
)
{
char
**
split_fwd
=
g_strsplit
(
synctex_fwd
,
":"
,
0
);
if
(
split_fwd
==
NULL
||
split_fwd
[
0
]
==
NULL
||
split_fwd
[
1
]
==
NULL
||
split_fwd
[
2
]
==
NULL
||
split_fwd
[
3
]
!=
NULL
)
{
girara_error
(
"Failed to parse argument to --synctex-forward."
);
free
(
real_path
);
g_strfreev
(
split_fwd
);
return
-
1
;
}
const
int
line
=
MIN
(
INT_MAX
,
g_ascii_strtoll
(
split_fwd
[
0
],
NULL
,
10
));
const
int
column
=
MIN
(
INT_MAX
,
g_ascii_strtoll
(
split_fwd
[
1
],
NULL
,
10
));
const
bool
ret
=
zathura_dbus_synctex_position
(
real_path
,
split_fwd
[
2
],
line
,
column
,
synctex_pid
);
g_strfreev
(
split_fwd
);
if
(
ret
==
true
)
{
free
(
real_path
);
return
0
;
}
else
{
girara_error
(
"Could not find open instance for '%s' or got no usable
output
from
'
synctex
view'
."
,
real_path
);
girara_error
(
"Could not find open instance for '%s' or got no usable
data
from synctex."
,
real_path
);
free
(
real_path
);
return
-
1
;
}
...
...
synctex.c
View file @
2f53f09e
...
...
@@ -8,49 +8,12 @@
#include "page.h"
#include "document.h"
#include "utils.h"
enum
{
SYNCTEX_RESULT_BEGIN
=
1
,
SYNCTEX_RESULT_END
,
SYNCTEX_PROP_PAGE
,
SYNCTEX_PROP_H
,
SYNCTEX_PROP_V
,
SYNCTEX_PROP_WIDTH
,
SYNCTEX_PROP_HEIGHT
,
};
typedef
struct
token_s
{
const
char
*
name
;
guint
token
;
}
token_t
;
static
token_t
scanner_tokens
[]
=
{
{
"SyncTeX result begin"
,
SYNCTEX_RESULT_BEGIN
},
{
"SyncTeX result end"
,
SYNCTEX_RESULT_END
},
{
"Page:"
,
SYNCTEX_PROP_PAGE
},
{
"h:"
,
SYNCTEX_PROP_H
},
{
"v:"
,
SYNCTEX_PROP_V
},
{
"W:"
,
SYNCTEX_PROP_WIDTH
},
{
"H:"
,
SYNCTEX_PROP_HEIGHT
},
{
NULL
,
0
}
};
static
GScannerConfig
scanner_config
=
{
.
cset_skip_characters
=
"
\n\r
"
,
.
cset_identifier_first
=
G_CSET_a_2_z
G_CSET_A_2_Z
,
.
cset_identifier_nth
=
G_CSET_a_2_z
G_CSET_A_2_Z
": "
,
.
cpair_comment_single
=
NULL
,
.
case_sensitive
=
TRUE
,
.
scan_identifier
=
TRUE
,
.
scan_symbols
=
TRUE
,
.
scan_float
=
TRUE
,
.
numbers_2_int
=
TRUE
,
};
#include "synctex/synctex_parser.h"
void
synctex_edit
(
zathura_t
*
zathura
,
zathura_page_t
*
page
,
int
x
,
int
y
)
{
if
(
zathura
==
NULL
||
page
==
NULL
)
{
if
(
zathura
==
NULL
||
page
==
NULL
||
zathura
->
synctex
.
editor
==
NULL
)
{
return
;
}
...
...
@@ -64,212 +27,123 @@ synctex_edit(zathura_t* zathura, zathura_page_t* page, int x, int y)
return
;
}
char
**
argv
=
g_try_malloc0
(
sizeof
(
char
*
)
*
(
zathura
->
synctex
.
editor
!=
NULL
?
7
:
5
));
if
(
argv
==
NULL
)
{
synctex_scanner_t
scanner
=
synctex_scanner_new_with_output_file
(
filename
,
NULL
,
1
);
if
(
scanner
==
NULL
)
{
girara_debug
(
"Failed to create synctex scanner."
);
return
;
}
argv
[
0
]
=
g_strdup
(
"synctex"
);
argv
[
1
]
=
g_strdup
(
"edit"
);
argv
[
2
]
=
g_strdup
(
"-o"
);
argv
[
3
]
=
g_strdup_printf
(
"%d:%d:%d:%s"
,
zathura_page_get_index
(
page
)
+
1
,
x
,
y
,
filename
);
if
(
zathura
->
synctex
.
editor
!=
NULL
)
{
argv
[
4
]
=
g_strdup
(
"-x"
);
argv
[
5
]
=
g_strdup
(
zathura
->
synctex
.
editor
);
synctex_scanner_t
temp
=
synctex_scanner_parse
(
scanner
);
if
(
temp
==
NULL
)
{
girara_debug
(
"Failed to parse synctex file."
);
synctex_scanner_free
(
scanner
);
return
;
}
g_spawn_async
(
NULL
,
argv
,
NULL
,
G_SPAWN_SEARCH_PATH
,
NULL
,
NULL
,
NULL
,
NULL
);
g_strfreev
(
argv
);
}
if
(
synctex_edit_query
(
scanner
,
zathura_page_get_index
(
page
)
+
1
,
x
,
y
)
>
0
)
{
/* Assume that a backward search returns either at most one result. */
synctex_node_t
node
=
synctex_next_result
(
scanner
);
if
(
node
!=
NULL
)
{
const
char
*
input_file
=
synctex_scanner_get_name
(
scanner
,
synctex_node_tag
(
node
));
const
int
line
=
synctex_node_line
(
node
);
const
int
column
=
synctex_node_column
(
node
);
char
*
linestr
=
g_strdup_printf
(
"%d"
,
line
);
char
*
columnstr
=
g_strdup_printf
(
"%d"
,
column
);
gchar
**
argv
=
NULL
;
gint
argc
=
0
;
if
(
g_shell_parse_argv
(
zathura
->
synctex
.
editor
,
&
argc
,
&
argv
,
NULL
)
==
TRUE
)
{
for
(
gint
i
=
0
;
i
!=
argc
;
++
i
)
{
char
*
temp
=
girara_replace_substring
(
argv
[
i
],
"%{line}"
,
linestr
);
g_free
(
argv
[
i
]);
argv
[
i
]
=
temp
;
temp
=
girara_replace_substring
(
argv
[
i
],
"%{column}"
,
columnstr
);
g_free
(
argv
[
i
]);
argv
[
i
]
=
temp
;
temp
=
girara_replace_substring
(
argv
[
i
],
"%{input}"
,
input_file
);
g_free
(
argv
[
i
]);
argv
[
i
]
=
temp
;
}
static
double
scan_float
(
GScanner
*
scanner
)
{
switch
(
g_scanner_get_next_token
(
scanner
))
{
case
G_TOKEN_FLOAT
:
return
g_scanner_cur_value
(
scanner
).
v_float
;
case
G_TOKEN_INT
:
return
g_scanner_cur_value
(
scanner
).
v_int
;
default:
return
0
.
0
;
g_spawn_async
(
NULL
,
argv
,
NULL
,
G_SPAWN_SEARCH_PATH
,
NULL
,
NULL
,
NULL
,
NULL
);
g_strfreev
(
argv
);
}
g_free
(
linestr
);
g_free
(
columnstr
);
}
}
synctex_scanner_free
(
scanner
);
}
girara_list_t
*
synctex_rectangles_from_position
(
const
char
*
filename
,
const
char
*
position
,
unsigned
int
*
page
,
synctex_rectangles_from_position
(
const
char
*
filename
,
const
char
*
input_file
,
int
line
,
int
column
,
unsigned
int
*
page
,
girara_list_t
**
secondary_rects
)
{
if
(
filename
==
NULL
||
position
==
NULL
||
page
==
NULL
)
{
if
(
filename
==
NULL
||
input_file
==
NULL
||
page
==
NULL
)
{
return
NULL
;
}
char
**
argv
=
g_try_malloc0
(
sizeof
(
char
*
)
*
7
);
if
(
argv
==
NULL
)
{
synctex_scanner_t
scanner
=
synctex_scanner_new_with_output_file
(
filename
,
NULL
,
1
);
if
(
scanner
==
NULL
)
{
girara_debug
(
"Failed to create synctex scanner."
);
return
NULL
;
}
argv
[
0
]
=
g_strdup
(
"synctex"
);
argv
[
1
]
=
g_strdup
(
"view"
);
argv
[
2
]
=
g_strdup
(
"-i"
);
argv
[
3
]
=
g_strdup
(
position
);
argv
[
4
]
=
g_strdup
(
"-o"
);
argv
[
5
]
=
g_strdup
(
filename
);
gint
output
=
-
1
;
bool
ret
=
g_spawn_async_with_pipes
(
NULL
,
argv
,
NULL
,
G_SPAWN_SEARCH_PATH
|
G_SPAWN_STDERR_TO_DEV_NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
&
output
,
NULL
,
NULL
);
g_strfreev
(
argv
);
if
(
ret
==
false
)
{
return
false
;
}
GScanner
*
scanner
=
g_scanner_new
(
&
scanner_config
);
token_t
*
tokens
=
scanner_tokens
;
while
(
tokens
->
name
!=
NULL
)
{
g_scanner_add_symbol
(
scanner
,
tokens
->
name
,
GINT_TO_POINTER
(
tokens
->
token
));
tokens
++
;
}
g_scanner_input_file
(
scanner
,
output
);
bool
found_begin
=
false
,
found_end
=
false
;
while
(
found_begin
==
false
&&
found_end
==
false
)
{
switch
(
g_scanner_get_next_token
(
scanner
))
{
case
G_TOKEN_EOF
:
found_end
=
true
;
break
;
case
G_TOKEN_SYMBOL
:
switch
(
GPOINTER_TO_INT
(
g_scanner_cur_value
(
scanner
).
v_identifier
))
{
case
SYNCTEX_RESULT_BEGIN
:
found_begin
=
true
;
break
;
}
break
;
default:
/* skip everything else */
break
;
}
synctex_scanner_t
temp
=
synctex_scanner_parse
(
scanner
);
if
(
temp
==
NULL
)
{
girara_debug
(
"Failed to parse synctex file."
);
synctex_scanner_free
(
scanner
);
return
NULL
;
}
ret
=
false
;
unsigned
int
rpage
=
0
;
unsigned
int
current_page
=
0
;
girara_list_t
*
hitlist
=
girara_list_new2
(
g_free
);
girara_list_t
*
other_rects
=
girara_list_new2
(
g_free
);
bool
got_rect
=
false
;
zathura_rectangle_t
rectangle
;
while
(
found_end
==
false
)
{
switch
(
g_scanner_get_next_token
(
scanner
))
{
case
G_TOKEN_EOF
:
found_end
=
true
;
break
;
case
G_TOKEN_SYMBOL
:
switch
(
GPOINTER_TO_INT
(
g_scanner_cur_value
(
scanner
).
v_identifier
))
{
case
SYNCTEX_RESULT_END
:
found_end
=
true
;
break
;
case
SYNCTEX_PROP_PAGE
:
if
(
g_scanner_get_next_token
(
scanner
)
==
G_TOKEN_INT
)
{
current_page
=
g_scanner_cur_value
(
scanner
).
v_int
-
1
;
if
(
ret
==
false
)
{
ret
=
true
;
rpage
=
current_page
;
}
if
(
got_rect
==
false
)
{
continue
;
}
got_rect
=
false
;
if
(
*
page
==
current_page
)
{
zathura_rectangle_t
*
real_rect
=
g_try_malloc
(
sizeof
(
zathura_rectangle_t
));
if
(
real_rect
==
NULL
)
{
continue
;
}
*
real_rect
=
rectangle
;
girara_list_append
(
hitlist
,
real_rect
);
}
else
{
synctex_page_rect_t
*
page_rect
=
g_try_malloc
(
sizeof
(
synctex_page_rect_t
));
if
(
page_rect
==
NULL
)
{
continue
;
}
if
(
synctex_display_query
(
scanner
,
input_file
,
line
,
column
)
>
0
)
{
synctex_node_t
node
=
NULL
;
bool
got_page
=
false
;
page_rect
->
page
=
current_page
;
page_rect
->
rect
=
rectangle
;
girara_list_append
(
other_rects
,
page_rect
);
}
}
break
;
case
SYNCTEX_PROP_H
:
rectangle
.
x1
=
scan_float
(
scanner
);
got_rect
=
true
;
break
;
case
SYNCTEX_PROP_V
:
rectangle
.
y2
=
scan_float
(
scanner
);
got_rect
=
true
;
break
;
while
((
node
=
synctex_next_result
(
scanner
))
!=
NULL
)
{
const
unsigned
int
current_page
=
synctex_node_page
(
node
)
-
1
;
if
(
got_page
==
false
)
{
got_page
=
true
;
*
page
=
current_page
;
}
case
SYNCTEX_PROP_WIDTH
:
rectangle
.
x2
=
rectangle
.
x1
+
scan_float
(
scanner
);
got_rect
=
true
;
break
;
zathura_rectangle_t
rect
=
{
0
,
0
,
0
,
0
};
rect
.
x1
=
synctex_node_box_visible_h
(
node
);
rect
.
y1
=
synctex_node_box_visible_v
(
node
)
-
synctex_node_box_visible_height
(
node
);
rect
.
x2
=
rect
.
x1
+
synctex_node_box_visible_width
(
node
);
rect
.
y2
=
synctex_node_box_visible_depth
(
node
)
+
synctex_node_box_visible_height
(
node
)
+
rect
.
y1
;
case
SYNCTEX_PROP_HEIGHT
:
rectangle
.
y1
=
rectangle
.
y2
-
scan_float
(
scanner
);
got_rect
=
true
;
break
;
if
(
*
page
==
current_page
)
{
zathura_
rectangle
_t
*
real_rect
=
g_try_malloc
(
sizeof
(
zathura_rectangle_t
)
);
if
(
real_rect
==
NULL
)
{
continue
;
}
break
;
default:
break
;
}
}
if
(
got_rect
==
true
)
{
if
(
current_page
==
rpage
)
{
zathura_rectangle_t
*
real_rect
=
g_try_malloc
(
sizeof
(
zathura_rectangle_t
));
if
(
real_rect
!=
NULL
)
{
*
real_rect
=
rectangle
;
*
real_rect
=
rect
;
girara_list_append
(
hitlist
,
real_rect
);
}
}
else
{
synctex_page_rect_t
*
page_rect
=
g_try_malloc
(
sizeof
(
synctex_page_rect_t
));
if
(
page_rect
!=
NULL
)
{
}
else
{
synctex_page_rect_t
*
page_rect
=
g_try_malloc
(
sizeof
(
synctex_page_rect_t
));
if
(
page_rect
==
NULL
)
{
continue
;
}
page_rect
->
page
=
current_page
;
page_rect
->
rect
=
rectangle
;
page_rect
->
rect
=
rect
;
girara_list_append
(
other_rects
,
page_rect
);
}
}
}
g_scanner_destroy
(
scanner
);
close
(
output
);
synctex_scanner_free
(
scanner
);
if
(
ret
==
false
)
{
girara_debug
(
"Got no usable output from running synctex view."
);
girara_list_free
(
hitlist
);
girara_list_free
(
other_rects
);
return
NULL
;
}
if
(
page
!=
NULL
)
{
*
page
=
rpage
;
}
if
(
secondary_rects
!=
NULL
)
{
*
secondary_rects
=
other_rects
;
}
else
{
...
...
synctex.h
View file @
2f53f09e
...
...
@@ -12,6 +12,7 @@ typedef struct synctex_page_rect_s {
void
synctex_edit
(
zathura_t
*
zathura
,
zathura_page_t
*
page
,
int
x
,
int
y
);
girara_list_t
*
synctex_rectangles_from_position
(
const
char
*
filename
,
const
char
*
position
,
unsigned
int
*
page
,
girara_list_t
**
secondary_rects
);
const
char
*
input_file
,
int
line
,
int
column
,
unsigned
int
*
page
,
girara_list_t
**
secondary_rects
);
#endif
synctex/LICENSE
0 → 100644
View file @
2f53f09e
Copyright (c) 2008, 2009, 2010, 2011 jerome DOT laurens AT u-bourgogne DOT fr
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE