Skip to content

Commit 5c628bf

Browse files
committed
Add the --synctex command line option, gzip synctex
- Update tests.
1 parent 3cc0c8d commit 5c628bf

File tree

8 files changed

+23
-41
lines changed

8 files changed

+23
-41
lines changed

src/cli_driver.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ struct ProcessingSession {
260260
keep_intermediates: bool,
261261
keep_logs: bool,
262262
noted_tex_warnings: bool,
263+
synctex_enabled: bool,
263264
}
264265

265266

@@ -345,6 +346,7 @@ impl ProcessingSession {
345346
keep_intermediates: args.is_present("keep_intermediates"),
346347
keep_logs: args.is_present("keep_logs"),
347348
noted_tex_warnings: false,
349+
synctex_enabled: args.is_present("synctex"),
348350
})
349351
}
350352

@@ -639,6 +641,7 @@ impl ProcessingSession {
639641
let mut engine = TexEngine::new();
640642
engine.set_halt_on_error_mode(true);
641643
engine.set_initex_mode(true);
644+
engine.set_synctex(false);
642645
engine.process(&mut stack, &mut self.events, status, "UNUSED.fmt.gz",
643646
&format!("tectonic-format-{}.tex", stem))
644647
};
@@ -700,6 +703,7 @@ impl ProcessingSession {
700703
let mut engine = TexEngine::new();
701704
engine.set_halt_on_error_mode(true);
702705
engine.set_initex_mode(self.output_format == OutputFormat::Format);
706+
engine.set_synctex(self.synctex_enabled);
703707
if let Some(s) = rerun_explanation {
704708
status.note_highlighted("Rerunning ", "TeX", &format!(" because {} ...", s));
705709
} else {
@@ -848,6 +852,9 @@ fn main() {
848852
.arg(Arg::with_name("keep_logs")
849853
.long("keep-logs")
850854
.help("Keep the log files generated during processing."))
855+
.arg(Arg::with_name("synctex")
856+
.long("synctex")
857+
.help("Generate SyncTeX data."))
851858
.arg(Arg::with_name("hide")
852859
.long("hide")
853860
.value_name("PATH")

src/engines/tex.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ impl TexEngine {
4646
unsafe { super::tt_set_int_variable(b"in_initex_mode\0".as_ptr(), v); }
4747
}
4848

49+
pub fn set_synctex (&mut self, synctex_enabled: bool) {
50+
let v = if synctex_enabled { 1 } else { 0 };
51+
unsafe { super::tt_set_int_variable(b"synctex_enabled\0".as_ptr(), v); }
52+
}
53+
4954
// This function can't be generic across the IoProvider trait, for now,
5055
// since the global pointer that stashes the ExecutionState must have a
5156
// complete type.

tectonic/engine-interface.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ tt_set_int_variable (char *var_name, int value)
1717
halt_on_error_p = value;
1818
else if (STREQ (var_name, "in_initex_mode"))
1919
in_initex_mode = (value != 0);
20+
else if (STREQ (var_name, "synctex_enabled"))
21+
synctex_enabled = (value != 0);
2022
else
2123
return 1; /* Uh oh: unrecognized variable */
2224

tectonic/synctex.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ synctex_init_command(void)
151151
synctex_ctxt.flags.warn = 0;
152152
synctex_ctxt.flags.output_p = 0;
153153

154-
INTPAR(synctex) = 0; /* \synctex=0 : don't record stuff */
154+
if (synctex_enabled) {
155+
INTPAR(synctex) = 1;
156+
} else {
157+
INTPAR(synctex) = 0; /* \synctex=0 : don't record stuff */
158+
}
155159
}
156160

157161

@@ -233,10 +237,11 @@ synctex_dot_open(void)
233237
+ 1);
234238
strcpy(the_name, tmp);
235239
strcat(the_name, synctex_suffix);
240+
strcat(the_name, synctex_suffix_gz);
236241
free(tmp);
237242
tmp = NULL;
238243

239-
synctex_ctxt.file = ttstub_output_open(the_name, 0);
244+
synctex_ctxt.file = ttstub_output_open(the_name, 1);
240245
if (synctex_ctxt.file == NULL)
241246
goto fail;
242247

tectonic/xetexd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ scaled base_x_height;
687687
scaled base_width, base_height;
688688
scaled accent_width, accent_height;
689689
scaled delta;
690+
int synctex_enabled;
690691

691692
/*:1683*/
692693

tests/tex-outputs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn do_one(stem: &str, check_synctex: bool) {
148148
test_file(&xdvname, &expected_xdv, observed_xdv);
149149

150150
if check_synctex {
151-
p.set_extension("synctex");
151+
p.set_extension("synctex.gz");
152152
let expected_synctex = read_file(&p);
153153
let synctexname = p.file_name().unwrap().to_owned();
154154
let observed_synctex = files.get(&synctexname).unwrap();

tests/tex-outputs/synctex.synctex

Lines changed: 0 additions & 38 deletions
This file was deleted.

tests/tex-outputs/synctex.synctex.gz

333 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)