editors/texworks: Fix for TeX Live 2018.
Our in-tree version of texworks expects an older synctex than we now have in tree. This change fixes that. Bulk tested and OK kili@, thanks.
This commit is contained in:
parent
955fa02afa
commit
52e591d145
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.43 2019/01/02 17:40:44 kili Exp $
|
||||
# $OpenBSD: Makefile,v 1.44 2019/01/20 11:20:42 edd Exp $
|
||||
|
||||
COMMENT-main = easy to use LaTeX and ConTeXt editor
|
||||
COMMENT-python = Python scripting for TeXworks
|
||||
@ -13,7 +13,7 @@ PKGNAME-main = texworks-${V}
|
||||
PKGNAME-lua = texworks-lua-${V}
|
||||
PKGNAME-python = texworks-python-${V}
|
||||
|
||||
REVISION-main = 0
|
||||
REVISION-main = 1
|
||||
|
||||
EPOCH = 0
|
||||
|
||||
|
52
editors/texworks/patches/patch-src_TWSynchronizer_cpp
Normal file
52
editors/texworks/patches/patch-src_TWSynchronizer_cpp
Normal file
@ -0,0 +1,52 @@
|
||||
$OpenBSD: patch-src_TWSynchronizer_cpp,v 1.1 2019/01/20 11:20:45 edd Exp $
|
||||
|
||||
Make texworks build against a newer synctex:
|
||||
https://github.com/TeXworks/texworks/commit/496cc1785f335f0eb4451005025fe11ae295d3e4
|
||||
|
||||
Index: src/TWSynchronizer.cpp
|
||||
--- src/TWSynchronizer.cpp.orig
|
||||
+++ src/TWSynchronizer.cpp
|
||||
@@ -75,7 +75,7 @@ TWSynchronizer::PDFSyncPoint TWSyncTeXSynchronizer::sy
|
||||
// Find the name SyncTeX is using for this source file...
|
||||
const QFileInfo sourceFileInfo(src.filename);
|
||||
QDir curDir(QFileInfo(pdfFilename()).canonicalPath());
|
||||
- SyncTeX::synctex_node_t node = SyncTeX::synctex_scanner_input(_scanner);
|
||||
+ SyncTeX::synctex_node_p node = SyncTeX::synctex_scanner_input(_scanner);
|
||||
QString name;
|
||||
bool found = false;
|
||||
while (node) {
|
||||
@@ -92,8 +92,8 @@ TWSynchronizer::PDFSyncPoint TWSyncTeXSynchronizer::sy
|
||||
|
||||
retVal.filename = pdfFilename();
|
||||
|
||||
- if (SyncTeX::synctex_display_query(_scanner, name.toLocal8Bit().data(), src.line, src.col) > 0) {
|
||||
- while ((node = SyncTeX::synctex_next_result(_scanner)) != NULL) {
|
||||
+ if (SyncTeX::synctex_display_query(_scanner, name.toLocal8Bit().data(), src.line, src.col, -1) > 0) {
|
||||
+ while ((node = SyncTeX::synctex_scanner_next_result(_scanner)) != NULL) {
|
||||
if (retVal.page < 0)
|
||||
retVal.page = SyncTeX::synctex_node_page(node);
|
||||
if (SyncTeX::synctex_node_page(node) != retVal.page)
|
||||
@@ -122,8 +122,8 @@ TWSynchronizer::TeXSyncPoint TWSyncTeXSynchronizer::sy
|
||||
return retVal;
|
||||
|
||||
if (SyncTeX::synctex_edit_query(_scanner, src.page, src.rects[0].left(), src.rects[0].top()) > 0) {
|
||||
- SyncTeX::synctex_node_t node;
|
||||
- while ((node = SyncTeX::synctex_next_result(_scanner)) != NULL) {
|
||||
+ SyncTeX::synctex_node_p node;
|
||||
+ while ((node = SyncTeX::synctex_scanner_next_result(_scanner)) != NULL) {
|
||||
retVal.filename = QString::fromLocal8Bit(SyncTeX::synctex_scanner_get_name(_scanner, SyncTeX::synctex_node_tag(node)));
|
||||
retVal.line = SyncTeX::synctex_node_line(node);
|
||||
retVal.col = -1;
|
||||
@@ -215,9 +215,9 @@ void TWSyncTeXSynchronizer::_syncFromPDFFine(const TWS
|
||||
// than one PDF rect for multiline paragraphs).
|
||||
// Note: this still does not help for paragraphs broken across pages
|
||||
QList<QPolygonF> selection;
|
||||
- if (SyncTeX::synctex_display_query(_scanner, dest.filename.toLocal8Bit().data(), dest.line, -1) > 0) {
|
||||
- SyncTeX::synctex_node_t node;
|
||||
- while ((node = SyncTeX::synctex_next_result(_scanner)) != NULL) {
|
||||
+ if (SyncTeX::synctex_display_query(_scanner, dest.filename.toLocal8Bit().data(), dest.line, -1, src.page) > 0) {
|
||||
+ SyncTeX::synctex_node_p node;
|
||||
+ while ((node = SyncTeX::synctex_scanner_next_result(_scanner)) != NULL) {
|
||||
if (SyncTeX::synctex_node_page(node) != src.page)
|
||||
continue;
|
||||
QRectF nodeRect(synctex_node_box_visible_h(node),
|
17
editors/texworks/patches/patch-src_TWSynchronizer_h
Normal file
17
editors/texworks/patches/patch-src_TWSynchronizer_h
Normal file
@ -0,0 +1,17 @@
|
||||
$OpenBSD: patch-src_TWSynchronizer_h,v 1.1 2019/01/20 11:20:45 edd Exp $
|
||||
|
||||
Make texworks build against a newer synctex:
|
||||
https://github.com/TeXworks/texworks/commit/496cc1785f335f0eb4451005025fe11ae295d3e4
|
||||
|
||||
Index: src/TWSynchronizer.h
|
||||
--- src/TWSynchronizer.h.orig
|
||||
+++ src/TWSynchronizer.h
|
||||
@@ -72,7 +72,7 @@ class TWSyncTeXSynchronizer : public TWSynchronizer (p
|
||||
|
||||
static int _findCorrespondingPosition(const QString & srcContext, const QString & destContext, const int col, bool & unique);
|
||||
|
||||
- SyncTeX::synctex_scanner_t _scanner;
|
||||
+ SyncTeX::synctex_scanner_p _scanner;
|
||||
};
|
||||
|
||||
#endif // !defined(TW_SYNCHRONIZER_H)
|
12438
editors/texworks/patches/patch-src_synctex_parser_c
Normal file
12438
editors/texworks/patches/patch-src_synctex_parser_c
Normal file
File diff suppressed because it is too large
Load Diff
774
editors/texworks/patches/patch-src_synctex_parser_h
Normal file
774
editors/texworks/patches/patch-src_synctex_parser_h
Normal file
@ -0,0 +1,774 @@
|
||||
$OpenBSD: patch-src_synctex_parser_h,v 1.1 2019/01/20 11:20:45 edd Exp $
|
||||
|
||||
Make texworks build against a newer synctex:
|
||||
https://github.com/TeXworks/texworks/commit/496cc1785f335f0eb4451005025fe11ae295d3e4
|
||||
|
||||
Index: src/synctex_parser.h
|
||||
--- src/synctex_parser.h.orig
|
||||
+++ src/synctex_parser.h
|
||||
@@ -1,55 +1,50 @@
|
||||
-/*
|
||||
-Copyright (c) 2008, 2009, 2010 , 2011 jerome DOT laurens AT u-bourgogne DOT fr
|
||||
-
|
||||
-This file is part of the SyncTeX package.
|
||||
-
|
||||
-Latest Revision: Tue Jun 14 08:23:30 UTC 2011
|
||||
-
|
||||
-Version: 1.18
|
||||
-
|
||||
-See synctex_parser_readme.txt for more details
|
||||
-
|
||||
-License:
|
||||
---------
|
||||
-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
|
||||
-
|
||||
-Except as contained in this notice, the name of the copyright holder
|
||||
-shall not be used in advertising or otherwise to promote the sale,
|
||||
-use or other dealings in this Software without prior written
|
||||
-authorization from the copyright holder.
|
||||
-
|
||||
-Acknowledgments:
|
||||
-----------------
|
||||
-The author received useful remarks from the pdfTeX developers, especially Hahn The Thanh,
|
||||
-and significant help from XeTeX developer Jonathan Kew
|
||||
-
|
||||
-Nota Bene:
|
||||
-----------
|
||||
-If you include or use a significant part of the synctex package into a software,
|
||||
-I would appreciate to be listed as contributor and see "SyncTeX" highlighted.
|
||||
-
|
||||
-Version 1
|
||||
-Thu Jun 19 09:39:21 UTC 2008
|
||||
-
|
||||
+/*
|
||||
+ Copyright (c) 2008-2017 jerome DOT laurens AT u-bourgogne DOT fr
|
||||
+
|
||||
+ This file is part of the __SyncTeX__ package.
|
||||
+
|
||||
+ [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017)
|
||||
+ [//]: # (Version: 1.19)
|
||||
+
|
||||
+ See `synctex_parser_readme.md` for more details
|
||||
+
|
||||
+ ## License
|
||||
+
|
||||
+ 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
|
||||
+
|
||||
+ Except as contained in this notice, the name of the copyright holder
|
||||
+ shall not be used in advertising or otherwise to promote the sale,
|
||||
+ use or other dealings in this Software without prior written
|
||||
+ authorization from the copyright holder.
|
||||
+
|
||||
+ ## Acknowledgments:
|
||||
+
|
||||
+ The author received useful remarks from the __pdfTeX__ developers, especially Hahn The Thanh,
|
||||
+ and significant help from __XeTeX__ developer Jonathan Kew.
|
||||
+
|
||||
+ ## Nota Bene:
|
||||
+
|
||||
+ If you include or use a significant part of the __SyncTeX__ package into a software,
|
||||
+ I would appreciate to be listed as contributor and see "__SyncTeX__" highlighted.
|
||||
*/
|
||||
|
||||
#ifndef __SYNCTEX_PARSER__
|
||||
@@ -58,303 +53,369 @@ Thu Jun 19 09:39:21 UTC 2008
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
+
|
||||
+# define SYNCTEX_VERSION_STRING "1.19"
|
||||
+
|
||||
+ /* The main synctex object is a scanner.
|
||||
+ * Its implementation is considered private.
|
||||
+ * The basic workflow is
|
||||
+ * - create a "synctex scanner" with the contents of a file
|
||||
+ * - perform actions on that scanner like
|
||||
+ synctex_display_query or synctex_edit_query below.
|
||||
+ * - perform actions on nodes returned by the scanner
|
||||
+ * - free the scanner when the work is done
|
||||
+ */
|
||||
+ typedef struct synctex_scanner_t synctex_scanner_s;
|
||||
+ typedef synctex_scanner_s * synctex_scanner_p;
|
||||
+
|
||||
+ /**
|
||||
+ * This is the designated method to create
|
||||
+ * a new synctex scanner object.
|
||||
+ * - argument output: the pdf/dvi/xdv file associated
|
||||
+ * to the synctex file.
|
||||
+ * If necessary, it can be the tex file that
|
||||
+ * originated the synctex file but this might cause
|
||||
+ * problems if the \jobname has a custom value.
|
||||
+ * Despite this method can accept a relative path
|
||||
+ * in practice, you should only pass full paths.
|
||||
+ * The path should be encoded by the underlying
|
||||
+ * file system, assuming that it is based on
|
||||
+ * 8 bits characters, including UTF8,
|
||||
+ * not 16 bits nor 32 bits.
|
||||
+ * The last file extension is removed and
|
||||
+ * replaced by the proper extension,
|
||||
+ * either synctex or synctex.gz.
|
||||
+ * - argument build_directory: It is the directory where
|
||||
+ * all the auxiliary stuff is created.
|
||||
+ * If no synctex file is found in the same directory
|
||||
+ * as the output file, then we try to find one in
|
||||
+ * this build directory.
|
||||
+ * It is the directory where all the auxiliary
|
||||
+ * stuff is created. Sometimes, the synctex output
|
||||
+ * file and the pdf, dvi or xdv files are not
|
||||
+ * created in the same location. See MikTeX.
|
||||
+ * This directory path can be NULL,
|
||||
+ * it will be ignored then.
|
||||
+ * It can be either absolute or relative to the
|
||||
+ * directory of the output pdf (dvi or xdv) file.
|
||||
+ * Please note that this new argument is provided
|
||||
+ * as a convenience but should not be used.
|
||||
+ * Available since version 1.5.
|
||||
+ * - argument parse: In general, use 1.
|
||||
+ * Use 0 only if you do not want to parse the
|
||||
+ * content but just check for existence.
|
||||
+ * Available since version 1.5
|
||||
+ * - resturn: a scanner. NULL is returned in case
|
||||
+ * of an error or non existent file.
|
||||
+ */
|
||||
+ synctex_scanner_p synctex_scanner_new_with_output_file(const char * output, const char * build_directory, int parse);
|
||||
+
|
||||
+ /**
|
||||
+ * Designated method to delete a synctex scanner object,
|
||||
+ * including all its internal resources.
|
||||
+ * Frees all the memory, you must call it when you are finished with the scanner.
|
||||
+ * - argument scanner: a scanner.
|
||||
+ * - returns: an integer used for testing purposes.
|
||||
+ */
|
||||
+ int synctex_scanner_free(synctex_scanner_p scanner);
|
||||
+
|
||||
+ /**
|
||||
+ * Send this message to force the scanner to
|
||||
+ * parse the contents of the synctex output file.
|
||||
+ * Nothing is performed if the file was already parsed.
|
||||
+ * In each query below, this message is sent,
|
||||
+ * but if you need to access information more directly,
|
||||
+ * you must ensure that the parsing did occur.
|
||||
+ * Usage:
|
||||
+ * if((my_scanner = synctex_scanner_parse(my_scanner))) {
|
||||
+ * continue with my_scanner...
|
||||
+ * } else {
|
||||
+ * there was a problem
|
||||
+ * }
|
||||
+ * - returns: the argument on success.
|
||||
+ * On failure, frees scanner and returns NULL.
|
||||
+ */
|
||||
+ synctex_scanner_p synctex_scanner_parse(synctex_scanner_p scanner);
|
||||
+
|
||||
+ /* synctex_node_p is the type for all synctex nodes.
|
||||
+ * Its implementation is considered private.
|
||||
+ * The synctex file is parsed into a tree of nodes, either sheet, form, boxes, math nodes... */
|
||||
+
|
||||
+ typedef struct synctex_node_t synctex_node_s;
|
||||
+ typedef synctex_node_s * synctex_node_p;
|
||||
+
|
||||
+ /* The main entry points.
|
||||
+ * Given the file name, a line and a column number, synctex_display_query returns the number of nodes
|
||||
+ * satisfying the contrain. Use code like
|
||||
+ *
|
||||
+ * if(synctex_display_query(scanner,name,line,column,page_hint)>0) {
|
||||
+ * synctex_node_p node;
|
||||
+ * while((node = synctex_scanner_next_result(scanner))) {
|
||||
+ * // do something with node
|
||||
+ * ...
|
||||
+ * }
|
||||
+ * }
|
||||
+ *
|
||||
+ * Please notice that since version 1.19,
|
||||
+ * there is a new argument page_hint.
|
||||
+ * The results in pages closer to page_hint are given first.
|
||||
+ * For example, one can
|
||||
+ * - highlight each resulting node in the output, using synctex_node_visible_h and synctex_node_visible_v
|
||||
+ * - highlight all the rectangles enclosing those nodes, using synctex_node_box_visible_... functions
|
||||
+ * - highlight just the character using that information
|
||||
+ *
|
||||
+ * Given the page and the position in the page, synctex_edit_query returns the number of nodes
|
||||
+ * satisfying the contrain. Use code like
|
||||
+ *
|
||||
+ * if(synctex_edit_query(scanner,page,h,v)>0) {
|
||||
+ * synctex_node_p node;
|
||||
+ * while(node = synctex_scanner_next_result(scanner)) {
|
||||
+ * // do something with node
|
||||
+ * ...
|
||||
+ * }
|
||||
+ * }
|
||||
+ *
|
||||
+ * For example, one can
|
||||
+ * - highlight each resulting line in the input,
|
||||
+ * - highlight just the character using that information
|
||||
+ *
|
||||
+ * page is 1 based
|
||||
+ * h and v are coordinates in 72 dpi unit, relative to the top left corner of the page.
|
||||
+ * If you make a new query, the result of the previous one is discarded. If you need to make more than one query
|
||||
+ * in parallel, use the iterator API exposed in
|
||||
+ * the synctex_parser_private.h header.
|
||||
+ * If one of this function returns a negative integer,
|
||||
+ * it means that an error occurred.
|
||||
+ *
|
||||
+ * Both methods are conservative, in the sense that matching is weak.
|
||||
+ * If the exact column number is not found, there will be an answer with the whole line.
|
||||
+ *
|
||||
+ * Sumatra-PDF, Skim, iTeXMac2, TeXShop and Texworks are examples of open source software that use this library.
|
||||
+ * You can browse their code for a concrete implementation.
|
||||
+ */
|
||||
+ typedef long synctex_status_t;
|
||||
+ /* The page_hint argument is used to resolve ambiguities.
|
||||
+ * Whenever, different matches occur, the ones closest
|
||||
+ * to the page will be given first. Pass a negative number
|
||||
+ * when in doubt. Using pdf forms may lead to ambiguities.
|
||||
+ */
|
||||
+ synctex_status_t synctex_display_query(synctex_scanner_p scanner,const char * name,int line,int column, int page_hint);
|
||||
+ synctex_status_t synctex_edit_query(synctex_scanner_p scanner,int page,float h,float v);
|
||||
+ synctex_node_p synctex_scanner_next_result(synctex_scanner_p scanner);
|
||||
+ synctex_status_t synctex_scanner_reset_result(synctex_scanner_p scanner);
|
||||
+
|
||||
+ /**
|
||||
+ * The horizontal and vertical location,
|
||||
+ * the width, height and depth of a box enclosing node.
|
||||
+ * All dimensions are given in page coordinates
|
||||
+ * as opposite to TeX coordinates.
|
||||
+ * The origin is at the top left corner of the page.
|
||||
+ * Code example for Qt5:
|
||||
+ * (from TeXworks source TWSynchronize.cpp)
|
||||
+ * QRectF nodeRect(synctex_node_box_visible_h(node),
|
||||
+ * synctex_node_box_visible_v(node) -
|
||||
+ * synctex_node_box_visible_height(node),
|
||||
+ * synctex_node_box_visible_width(node),
|
||||
+ * synctex_node_box_visible_height(node) +
|
||||
+ * synctex_node_box_visible_depth(node));
|
||||
+ * Code example for Cocoa:
|
||||
+ * NSRect bounds = [pdfPage
|
||||
+ * boundsForBox:kPDFDisplayBoxMediaBox];
|
||||
+ * NSRect nodeRect = NSMakeRect(
|
||||
+ * synctex_node_box_visible_h(node),
|
||||
+ * NSMaxY(bounds)-synctex_node_box_visible_v(node) +
|
||||
+ * synctex_node_box_visible_height(node),
|
||||
+ * synctex_node_box_visible_width(node),
|
||||
+ * synctex_node_box_visible_height(node) +
|
||||
+ * synctex_node_box_visible_depth(node)
|
||||
+ * );
|
||||
+ * The visible dimensions are bigger than real ones
|
||||
+ * to compensate 0 width boxes or nodes intentionnaly
|
||||
+ * put outside the box (using \kern for example).
|
||||
+ * - parameter node: a node.
|
||||
+ * - returns: a float.
|
||||
+ * - author: JL
|
||||
+ */
|
||||
+ float synctex_node_box_visible_h(synctex_node_p node);
|
||||
+ float synctex_node_box_visible_v(synctex_node_p node);
|
||||
+ float synctex_node_box_visible_width(synctex_node_p node);
|
||||
+ float synctex_node_box_visible_height(synctex_node_p node);
|
||||
+ float synctex_node_box_visible_depth(synctex_node_p node);
|
||||
|
||||
-# define SYNCTEX_VERSION_STRING "1.18"
|
||||
+ /**
|
||||
+ * For quite all nodes, horizontal and vertical coordinates, and width.
|
||||
+ * All dimensions are given in page coordinates
|
||||
+ * as opposite to TeX coordinates.
|
||||
+ * The origin is at the top left corner of the page.
|
||||
+ * The visible dimensions are bigger than real ones
|
||||
+ * to compensate 0 width boxes or nodes intentionnaly
|
||||
+ * put outside the box (using \kern for example).
|
||||
+ * All nodes have coordinates, but all nodes don't
|
||||
+ * have non null size. For example, math nodes
|
||||
+ * have no width according to TeX, and in that case
|
||||
+ * synctex_node_visible_width simply returns 0.
|
||||
+ * The same holds for kern nodes that do not have
|
||||
+ * height nor depth, etc...
|
||||
+ */
|
||||
+ float synctex_node_visible_h(synctex_node_p node);
|
||||
+ float synctex_node_visible_v(synctex_node_p node);
|
||||
+ float synctex_node_visible_width(synctex_node_p node);
|
||||
+ float synctex_node_visible_height(synctex_node_p node);
|
||||
+ float synctex_node_visible_depth(synctex_node_p node);
|
||||
|
||||
-/* synctex_node_t is the type for all synctex nodes.
|
||||
- * The synctex file is parsed into a tree of nodes, either sheet, boxes, math nodes... */
|
||||
-typedef struct _synctex_node * synctex_node_t;
|
||||
+ /**
|
||||
+ * Given a node, access to its tag, line and column.
|
||||
+ * The line and column numbers are 1 based.
|
||||
+ * The latter is not yet fully supported in TeX,
|
||||
+ * the default implementation returns 0
|
||||
+ * which means the whole line.
|
||||
+ * synctex_node_get_name returns the path of the
|
||||
+ * TeX source file that was used to create the node.
|
||||
+ * When the tag is known, the scanner of the node
|
||||
+ * will also give that same file name, see
|
||||
+ * synctex_scanner_get_name below.
|
||||
+ */
|
||||
+ int synctex_node_tag(synctex_node_p node);
|
||||
+ int synctex_node_line(synctex_node_p node);
|
||||
+ int synctex_node_column(synctex_node_p node);
|
||||
+ const char * synctex_node_get_name(synctex_node_p node);
|
||||
+
|
||||
|
||||
-/* The main synctex object is a scanner
|
||||
- * Its implementation is considered private.
|
||||
- * The basic workflow is
|
||||
- * - create a "synctex scanner" with the contents of a file
|
||||
- * - perform actions on that scanner like display or edit queries
|
||||
- * - free the scanner when the work is done
|
||||
- */
|
||||
-typedef struct __synctex_scanner_t _synctex_scanner_t;
|
||||
-typedef _synctex_scanner_t * synctex_scanner_t;
|
||||
+ /**
|
||||
+ This is the page where the node appears.
|
||||
+ * This is a 1 based index as given by TeX.
|
||||
+ */
|
||||
+ int synctex_node_page(synctex_node_p node);
|
||||
|
||||
-/* This is the designated method to create a new synctex scanner object.
|
||||
- * output is the pdf/dvi/xdv file associated to the synctex file.
|
||||
- * If necessary, it can be the tex file that originated the synctex file
|
||||
- * but this might cause problems if the \jobname has a custom value.
|
||||
- * Despite this method can accept a relative path in practice,
|
||||
- * you should only pass a full path name.
|
||||
- * The path should be encoded by the underlying file system,
|
||||
- * assuming that it is based on 8 bits characters, including UTF8,
|
||||
- * not 16 bits nor 32 bits.
|
||||
- * The last file extension is removed and replaced by the proper extension.
|
||||
- * Then the private method _synctex_scanner_new_with_contents_of_file is called.
|
||||
- * NULL is returned in case of an error or non existent file.
|
||||
- * Once you have a scanner, use the synctex_display_query and synctex_edit_query below.
|
||||
- * The new "build_directory" argument is available since version 1.5.
|
||||
- * It is the directory where all the auxiliary stuff is created.
|
||||
- * Sometimes, the synctex output file and the pdf, dvi or xdv files are not created in the same directory.
|
||||
- * This is the case in MikTeX (I will include this into TeX Live).
|
||||
- * This directory path can be nil, it will be ignored then.
|
||||
- * It can be either absolute or relative to the directory of the output pdf (dvi or xdv) file.
|
||||
- * If no synctex file is found in the same directory as the output file, then we try to find one in the build directory.
|
||||
- * Please note that this new "build_directory" is provided as a convenient argument but should not be used.
|
||||
- * In fact, this is implempented as a work around of a bug in MikTeX where the synctex file does not follow the pdf file.
|
||||
- * The new "parse" argument is available since version 1.5. In general, use 1.
|
||||
- * Use 0 only if you do not want to parse the content but just check the existence.
|
||||
- */
|
||||
-synctex_scanner_t synctex_scanner_new_with_output_file(const char * output, const char * build_directory, int parse);
|
||||
-
|
||||
-/* This is the designated method to delete a synctex scanner object.
|
||||
- * Frees all the memory, you must call it when you are finished with the scanner.
|
||||
- */
|
||||
-void synctex_scanner_free(synctex_scanner_t scanner);
|
||||
-
|
||||
-/* Send this message to force the scanner to parse the contents of the synctex output file.
|
||||
- * Nothing is performed if the file was already parsed.
|
||||
- * In each query below, this message is sent, but if you need to access information more directly,
|
||||
- * you must be sure that the parsing did occur.
|
||||
- * Usage:
|
||||
- * if((my_scanner = synctex_scanner_parse(my_scanner))) {
|
||||
- * continue with my_scanner...
|
||||
- * } else {
|
||||
- * there was a problem
|
||||
- * }
|
||||
- */
|
||||
-synctex_scanner_t synctex_scanner_parse(synctex_scanner_t scanner);
|
||||
-
|
||||
-/* The main entry points.
|
||||
- * Given the file name, a line and a column number, synctex_display_query returns the number of nodes
|
||||
- * satisfying the contrain. Use code like
|
||||
- *
|
||||
- * if(synctex_display_query(scanner,name,line,column)>0) {
|
||||
- * synctex_node_t node;
|
||||
- * while((node = synctex_next_result(scanner))) {
|
||||
- * // do something with node
|
||||
- * ...
|
||||
- * }
|
||||
- * }
|
||||
- *
|
||||
- * For example, one can
|
||||
- * - highlight each resulting node in the output, using synctex_node_h and synctex_node_v
|
||||
- * - highlight all the rectangles enclosing those nodes, using synctex_box_... functions
|
||||
- * - highlight just the character using that information
|
||||
- *
|
||||
- * Given the page and the position in the page, synctex_edit_query returns the number of nodes
|
||||
- * satisfying the contrain. Use code like
|
||||
- *
|
||||
- * if(synctex_edit_query(scanner,page,h,v)>0) {
|
||||
- * synctex_node_t node;
|
||||
- * while(node = synctex_next_result(scanner)) {
|
||||
- * // do something with node
|
||||
- * ...
|
||||
- * }
|
||||
- * }
|
||||
- *
|
||||
- * For example, one can
|
||||
- * - highlight each resulting line in the input,
|
||||
- * - highlight just the character using that information
|
||||
- *
|
||||
- * page is 1 based
|
||||
- * h and v are coordinates in 72 dpi unit, relative to the top left corner of the page.
|
||||
- * If you make a new query, the result of the previous one is discarded.
|
||||
- * If one of this function returns a non positive integer,
|
||||
- * it means that an error occurred.
|
||||
- *
|
||||
- * Both methods are conservative, in the sense that matching is weak.
|
||||
- * If the exact column number is not found, there will be an answer with the whole line.
|
||||
- *
|
||||
- * Sumatra-PDF, Skim, iTeXMac2 and Texworks are examples of open source software that use this library.
|
||||
- * You can browse their code for a concrete implementation.
|
||||
- */
|
||||
-typedef long synctex_status_t;
|
||||
-synctex_status_t synctex_display_query(synctex_scanner_t scanner,const char * name,int line,int column);
|
||||
-synctex_status_t synctex_edit_query(synctex_scanner_t scanner,int page,float h,float v);
|
||||
-synctex_node_t synctex_next_result(synctex_scanner_t scanner);
|
||||
-
|
||||
-/* Display all the information contained in the scanner object.
|
||||
- * If the records are too numerous, only the first ones are displayed.
|
||||
- * This is mainly for informatinal purpose to help developers.
|
||||
- */
|
||||
-void synctex_scanner_display(synctex_scanner_t scanner);
|
||||
-
|
||||
-/* The x and y offset of the origin in TeX coordinates. The magnification
|
||||
- These are used by pdf viewers that want to display the real box size.
|
||||
- For example, getting the horizontal coordinates of a node would require
|
||||
- synctex_node_box_h(node)*synctex_scanner_magnification(scanner)+synctex_scanner_x_offset(scanner)
|
||||
- Getting its TeX width would simply require
|
||||
- synctex_node_box_width(node)*synctex_scanner_magnification(scanner)
|
||||
- but direct methods are available for that below.
|
||||
- */
|
||||
-int synctex_scanner_x_offset(synctex_scanner_t scanner);
|
||||
-int synctex_scanner_y_offset(synctex_scanner_t scanner);
|
||||
-float synctex_scanner_magnification(synctex_scanner_t scanner);
|
||||
-
|
||||
-/* Managing the input file names.
|
||||
- * Given a tag, synctex_scanner_get_name will return the corresponding file name.
|
||||
- * Conversely, given a file name, synctex_scanner_get_tag will retur, the corresponding tag.
|
||||
- * The file name must be the very same as understood by TeX.
|
||||
- * For example, if you \input myDir/foo.tex, the file name is myDir/foo.tex.
|
||||
- * No automatic path expansion is performed.
|
||||
- * Finally, synctex_scanner_input is the first input node of the scanner.
|
||||
- * To browse all the input node, use a loop like
|
||||
- *
|
||||
- * if((input_node = synctex_scanner_input(scanner))){
|
||||
- * do {
|
||||
- * blah
|
||||
- * } while((input_node=synctex_node_sibling(input_node)));
|
||||
- * }
|
||||
- *
|
||||
- * The output is the name that was used to create the scanner.
|
||||
- * The synctex is the real name of the synctex file,
|
||||
- * it was obtained from output by setting the proper file extension.
|
||||
- */
|
||||
-const char * synctex_scanner_get_name(synctex_scanner_t scanner,int tag);
|
||||
-int synctex_scanner_get_tag(synctex_scanner_t scanner,const char * name);
|
||||
-synctex_node_t synctex_scanner_input(synctex_scanner_t scanner);
|
||||
-const char * synctex_scanner_get_output(synctex_scanner_t scanner);
|
||||
-const char * synctex_scanner_get_synctex(synctex_scanner_t scanner);
|
||||
-
|
||||
-/* Browsing the nodes
|
||||
- * parent, child and sibling are standard names for tree nodes.
|
||||
- * The parent is one level higher, the child is one level deeper,
|
||||
- * and the sibling is at the same level.
|
||||
- * The sheet of a node is the first ancestor, it is of type sheet.
|
||||
- * A node and its sibling have the same parent.
|
||||
- * A node is the parent of its child.
|
||||
- * A node is either the child of its parent,
|
||||
- * or belongs to the sibling chain of its parent's child.
|
||||
- * The next node is either the child, the sibling or the parent's sibling,
|
||||
- * unless the parent is a sheet.
|
||||
- * This allows to navigate through all the nodes of a given sheet node:
|
||||
- *
|
||||
- * synctex_node_t node = sheet;
|
||||
- * while((node = synctex_node_next(node))) {
|
||||
- * // do something with node
|
||||
- * }
|
||||
- *
|
||||
- * With synctex_sheet_content, you can retrieve the sheet node given the page.
|
||||
- * The page is 1 based, according to TeX standards.
|
||||
- * Conversely synctex_node_sheet allows to retrieve the sheet containing a given node.
|
||||
- */
|
||||
-synctex_node_t synctex_node_parent(synctex_node_t node);
|
||||
-synctex_node_t synctex_node_sheet(synctex_node_t node);
|
||||
-synctex_node_t synctex_node_child(synctex_node_t node);
|
||||
-synctex_node_t synctex_node_sibling(synctex_node_t node);
|
||||
-synctex_node_t synctex_node_next(synctex_node_t node);
|
||||
-synctex_node_t synctex_sheet(synctex_scanner_t scanner,int page);
|
||||
-synctex_node_t synctex_sheet_content(synctex_scanner_t scanner,int page);
|
||||
-
|
||||
-/* These are the types of the synctex nodes */
|
||||
-typedef enum {
|
||||
- synctex_node_type_error = 0,
|
||||
- synctex_node_type_input,
|
||||
- synctex_node_type_sheet,
|
||||
- synctex_node_type_vbox,
|
||||
- synctex_node_type_void_vbox,
|
||||
- synctex_node_type_hbox,
|
||||
- synctex_node_type_void_hbox,
|
||||
- synctex_node_type_kern,
|
||||
- synctex_node_type_glue,
|
||||
- synctex_node_type_math,
|
||||
- synctex_node_type_boundary,
|
||||
- synctex_node_number_of_types
|
||||
-} synctex_node_type_t;
|
||||
-
|
||||
-/* synctex_node_type gives the type of a given node,
|
||||
- * synctex_node_isa gives the same information as a human readable text. */
|
||||
-synctex_node_type_t synctex_node_type(synctex_node_t node);
|
||||
-const char * synctex_node_isa(synctex_node_t node);
|
||||
-
|
||||
-/* This is primarily used for debugging purpose.
|
||||
- * The second one logs information for the node and recursively displays information for its next node */
|
||||
-void synctex_node_log(synctex_node_t node);
|
||||
-void synctex_node_display(synctex_node_t node);
|
||||
-
|
||||
-/* Given a node, access to the location in the synctex file where it is defined.
|
||||
- */
|
||||
-typedef unsigned int synctex_charindex_t;
|
||||
-synctex_charindex_t synctex_node_charindex(synctex_node_t node);
|
||||
-
|
||||
-/* Given a node, access to its tag, line and column.
|
||||
- * The line and column numbers are 1 based.
|
||||
- * The latter is not yet fully supported in TeX, the default implementation returns 0 which means the whole line.
|
||||
- * When the tag is known, the scanner of the node will give the corresponding file name.
|
||||
- * When the tag is known, the scanner of the node will give the name.
|
||||
- */
|
||||
-int synctex_node_tag(synctex_node_t node);
|
||||
-int synctex_node_line(synctex_node_t node);
|
||||
-int synctex_node_column(synctex_node_t node);
|
||||
-
|
||||
-/* In order to enhance forward synchronization,
|
||||
- * non void horizontal boxes have supplemental cached information.
|
||||
- * The mean line is the average of the line numbers of the included nodes.
|
||||
- * The child count is the number of chidren.
|
||||
- */
|
||||
-int synctex_node_mean_line(synctex_node_t node);
|
||||
-int synctex_node_child_count(synctex_node_t node);
|
||||
-
|
||||
-/* This is the page where the node appears.
|
||||
- * This is a 1 based index as given by TeX.
|
||||
- */
|
||||
-int synctex_node_page(synctex_node_t node);
|
||||
-
|
||||
-/* For quite all nodes, horizontal, vertical coordinates, and width.
|
||||
- * These are expressed in TeX small points coordinates, with origin at the top left corner.
|
||||
- */
|
||||
-int synctex_node_h(synctex_node_t node);
|
||||
-int synctex_node_v(synctex_node_t node);
|
||||
-int synctex_node_width(synctex_node_t node);
|
||||
-
|
||||
-/* For all nodes, dimensions of the enclosing box.
|
||||
- * These are expressed in TeX small points coordinates, with origin at the top left corner.
|
||||
- * A box is enclosing itself.
|
||||
- */
|
||||
-int synctex_node_box_h(synctex_node_t node);
|
||||
-int synctex_node_box_v(synctex_node_t node);
|
||||
-int synctex_node_box_width(synctex_node_t node);
|
||||
-int synctex_node_box_height(synctex_node_t node);
|
||||
-int synctex_node_box_depth(synctex_node_t node);
|
||||
-
|
||||
-/* For quite all nodes, horizontal, vertical coordinates, and width.
|
||||
- * The visible dimensions are bigger than real ones to compensate 0 width boxes
|
||||
- * that do contain nodes.
|
||||
- * These are expressed in page coordinates, with origin at the top left corner.
|
||||
- * A box is enclosing itself.
|
||||
- */
|
||||
-float synctex_node_visible_h(synctex_node_t node);
|
||||
-float synctex_node_visible_v(synctex_node_t node);
|
||||
-float synctex_node_visible_width(synctex_node_t node);
|
||||
-/* For all nodes, visible dimensions of the enclosing box.
|
||||
- * A box is enclosing itself.
|
||||
- * The visible dimensions are bigger than real ones to compensate 0 width boxes
|
||||
- * that do contain nodes.
|
||||
- */
|
||||
-float synctex_node_box_visible_h(synctex_node_t node);
|
||||
-float synctex_node_box_visible_v(synctex_node_t node);
|
||||
-float synctex_node_box_visible_width(synctex_node_t node);
|
||||
-float synctex_node_box_visible_height(synctex_node_t node);
|
||||
-float synctex_node_box_visible_depth(synctex_node_t node);
|
||||
-
|
||||
-/* The main synctex updater object.
|
||||
- * This object is used to append information to the synctex file.
|
||||
- * Its implementation is considered private.
|
||||
- * It is used by the synctex command line tool to take into account modifications
|
||||
- * that could occur while postprocessing files by dvipdf like filters.
|
||||
- */
|
||||
-typedef struct __synctex_updater_t _synctex_updater_t;
|
||||
-typedef _synctex_updater_t * synctex_updater_t;
|
||||
-
|
||||
-/* Designated initializer.
|
||||
- * Once you are done with your whole job,
|
||||
- * free the updater */
|
||||
-synctex_updater_t synctex_updater_new_with_output_file(const char * output, const char * directory);
|
||||
-
|
||||
-/* Use the next functions to append records to the synctex file,
|
||||
- * no consistency tests made on the arguments */
|
||||
-void synctex_updater_append_magnification(synctex_updater_t updater, char * magnification);
|
||||
-void synctex_updater_append_x_offset(synctex_updater_t updater, char * x_offset);
|
||||
-void synctex_updater_append_y_offset(synctex_updater_t updater, char * y_offset);
|
||||
-
|
||||
-/* You MUST free the updater, once everything is properly appended */
|
||||
-void synctex_updater_free(synctex_updater_t updater);
|
||||
+ /**
|
||||
+ * Display all the information contained in the scanner.
|
||||
+ * If the records are too numerous, only the first ones are displayed.
|
||||
+ * This is mainly for informational purpose to help developers.
|
||||
+ */
|
||||
+ void synctex_scanner_display(synctex_scanner_p scanner);
|
||||
+
|
||||
+ /* Managing the input file names.
|
||||
+ * Given a tag, synctex_scanner_get_name will return the corresponding file name.
|
||||
+ * Conversely, given a file name, synctex_scanner_get_tag will return, the corresponding tag.
|
||||
+ * The file name must be the very same as understood by TeX.
|
||||
+ * For example, if you \input myDir/foo.tex, the file name is myDir/foo.tex.
|
||||
+ * No automatic path expansion is performed.
|
||||
+ * Finally, synctex_scanner_input is the first input node of the scanner.
|
||||
+ * To browse all the input node, use a loop like
|
||||
+ * ...
|
||||
+ * synctex_node_p = input_node;
|
||||
+ * ...
|
||||
+ * if((input_node = synctex_scanner_input(scanner))) {
|
||||
+ * do {
|
||||
+ * blah
|
||||
+ * } while((input_node=synctex_node_sibling(input_node)));
|
||||
+ * }
|
||||
+ *
|
||||
+ * The output is the name that was used to create the scanner.
|
||||
+ * The synctex is the real name of the synctex file,
|
||||
+ * it was obtained from output by setting the proper file extension.
|
||||
+ */
|
||||
+ const char * synctex_scanner_get_name(synctex_scanner_p scanner,int tag);
|
||||
+
|
||||
+ int synctex_scanner_get_tag(synctex_scanner_p scanner,const char * name);
|
||||
+
|
||||
+ synctex_node_p synctex_scanner_input(synctex_scanner_p scanner);
|
||||
+ synctex_node_p synctex_scanner_input_with_tag(synctex_scanner_p scanner,int tag);
|
||||
+ const char * synctex_scanner_get_output(synctex_scanner_p scanner);
|
||||
+ const char * synctex_scanner_get_synctex(synctex_scanner_p scanner);
|
||||
+
|
||||
+ /* The x and y offset of the origin in TeX coordinates. The magnification
|
||||
+ These are used by pdf viewers that want to display the real box size.
|
||||
+ For example, getting the horizontal coordinates of a node would require
|
||||
+ synctex_node_box_h(node)*synctex_scanner_magnification(scanner)+synctex_scanner_x_offset(scanner)
|
||||
+ Getting its TeX width would simply require
|
||||
+ synctex_node_box_width(node)*synctex_scanner_magnification(scanner)
|
||||
+ but direct methods are available for that below.
|
||||
+ */
|
||||
+ int synctex_scanner_x_offset(synctex_scanner_p scanner);
|
||||
+ int synctex_scanner_y_offset(synctex_scanner_p scanner);
|
||||
+ float synctex_scanner_magnification(synctex_scanner_p scanner);
|
||||
+
|
||||
+ /**
|
||||
+ * ## Browsing the nodes
|
||||
+ * parent, child and sibling are standard names for tree nodes.
|
||||
+ * The parent is one level higher,
|
||||
+ * the child is one level deeper,
|
||||
+ * and the sibling is at the same level.
|
||||
+ * A node and its sibling have the same parent.
|
||||
+ * A node is the parent of its children.
|
||||
+ * A node is either the child of its parent,
|
||||
+ * or belongs to the sibling chain of its parent's child.
|
||||
+ * The sheet or form of a node is the topmost ancestor,
|
||||
+ * it is of type sheet or form.
|
||||
+ * The next node is either the child, the sibling or the parent's sibling,
|
||||
+ * unless the parent is a sheet, a form or NULL.
|
||||
+ * This allows to navigate through all the nodes of a given sheet node:
|
||||
+ *
|
||||
+ * synctex_node_p node = sheet;
|
||||
+ * while((node = synctex_node_next(node))) {
|
||||
+ * // do something with node
|
||||
+ * }
|
||||
+ *
|
||||
+ * With synctex_sheet_content and synctex_form_content,
|
||||
+ * you can retrieve the sheet node given the page
|
||||
+ * or form tag.
|
||||
+ * The page is 1 based, according to TeX standards.
|
||||
+ * Conversely synctex_node_parent_sheet or
|
||||
+ * synctex_node_parent_form allows to retrieve
|
||||
+ * the sheet or the form containing a given node.
|
||||
+ * Notice that a node is not contained in a sheet
|
||||
+ * and a form at the same time.
|
||||
+ * Some nodes are not contained in either (handles).
|
||||
+ */
|
||||
+
|
||||
+ synctex_node_p synctex_node_parent(synctex_node_p node);
|
||||
+ synctex_node_p synctex_node_parent_sheet(synctex_node_p node);
|
||||
+ synctex_node_p synctex_node_parent_form(synctex_node_p node);
|
||||
+ synctex_node_p synctex_node_child(synctex_node_p node);
|
||||
+ synctex_node_p synctex_node_last_child(synctex_node_p node);
|
||||
+ synctex_node_p synctex_node_sibling(synctex_node_p node);
|
||||
+ synctex_node_p synctex_node_last_sibling(synctex_node_p node);
|
||||
+ synctex_node_p synctex_node_arg_sibling(synctex_node_p node);
|
||||
+ synctex_node_p synctex_node_next(synctex_node_p node);
|
||||
+
|
||||
+ /**
|
||||
+ * Top level entry points.
|
||||
+ * The scanner owns a list of sheet siblings and
|
||||
+ * a list of form siblings.
|
||||
+ * Sheets or forms have one child which is a box:
|
||||
+ * theie contents.
|
||||
+ * - argument page: 1 based sheet page number.
|
||||
+ * - argument tag: 1 based form tag number.
|
||||
+ */
|
||||
+ synctex_node_p synctex_sheet(synctex_scanner_p scanner,int page);
|
||||
+ synctex_node_p synctex_sheet_content(synctex_scanner_p scanner,int page);
|
||||
+ synctex_node_p synctex_form(synctex_scanner_p scanner,int tag);
|
||||
+ synctex_node_p synctex_form_content(synctex_scanner_p scanner,int tag);
|
||||
+
|
||||
+ /* This is primarily used for debugging purpose.
|
||||
+ * The second one logs information for the node and recursively displays information for its next node */
|
||||
+ void synctex_node_log(synctex_node_p node);
|
||||
+ void synctex_node_display(synctex_node_p node);
|
||||
+
|
||||
+ /* For quite all nodes, horizontal, vertical coordinates, and width.
|
||||
+ * These are expressed in TeX small points coordinates, with origin at the top left corner.
|
||||
+ */
|
||||
+ int synctex_node_h(synctex_node_p node);
|
||||
+ int synctex_node_v(synctex_node_p node);
|
||||
+ int synctex_node_width(synctex_node_p node);
|
||||
+ int synctex_node_height(synctex_node_p node);
|
||||
+ int synctex_node_depth(synctex_node_p node);
|
||||
+
|
||||
+ /* For all nodes, dimensions of the enclosing box.
|
||||
+ * These are expressed in TeX small points coordinates, with origin at the top left corner.
|
||||
+ * A box is enclosing itself.
|
||||
+ */
|
||||
+ int synctex_node_box_h(synctex_node_p node);
|
||||
+ int synctex_node_box_v(synctex_node_p node);
|
||||
+ int synctex_node_box_width(synctex_node_p node);
|
||||
+ int synctex_node_box_height(synctex_node_p node);
|
||||
+ int synctex_node_box_depth(synctex_node_p node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
239
editors/texworks/patches/patch-src_synctex_parser_utils_c
Normal file
239
editors/texworks/patches/patch-src_synctex_parser_utils_c
Normal file
@ -0,0 +1,239 @@
|
||||
$OpenBSD: patch-src_synctex_parser_utils_c,v 1.1 2019/01/20 11:20:45 edd Exp $
|
||||
|
||||
Make texworks build against a newer synctex:
|
||||
https://github.com/TeXworks/texworks/commit/496cc1785f335f0eb4451005025fe11ae295d3e4
|
||||
|
||||
Index: src/synctex_parser_utils.c
|
||||
--- src/synctex_parser_utils.c.orig
|
||||
+++ src/synctex_parser_utils.c
|
||||
@@ -1,42 +1,41 @@
|
||||
/*
|
||||
-Copyright (c) 2008, 2009, 2010 , 2011 jerome DOT laurens AT u-bourgogne DOT fr
|
||||
+ Copyright (c) 2008-2017 jerome DOT laurens AT u-bourgogne DOT fr
|
||||
+
|
||||
+ This file is part of the __SyncTeX__ package.
|
||||
+
|
||||
+ [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017)
|
||||
+ [//]: # (Version: 1.19)
|
||||
+
|
||||
+ See `synctex_parser_readme.md` for more details
|
||||
+
|
||||
+ ## License
|
||||
+
|
||||
+ 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
|
||||
+
|
||||
+ Except as contained in this notice, the name of the copyright holder
|
||||
+ shall not be used in advertising or otherwise to promote the sale,
|
||||
+ use or other dealings in this Software without prior written
|
||||
+ authorization from the copyright holder.
|
||||
|
||||
-This file is part of the SyncTeX package.
|
||||
-
|
||||
-Latest Revision: Tue Jun 14 08:23:30 UTC 2011
|
||||
-
|
||||
-Version: 1.18
|
||||
-
|
||||
-See synctex_parser_readme.txt for more details
|
||||
-
|
||||
-License:
|
||||
---------
|
||||
-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
|
||||
-
|
||||
-Except as contained in this notice, the name of the copyright holder
|
||||
-shall not be used in advertising or otherwise to promote the sale,
|
||||
-use or other dealings in this Software without prior written
|
||||
-authorization from the copyright holder.
|
||||
-
|
||||
*/
|
||||
|
||||
/* In this file, we find all the functions that may depend on the operating system. */
|
||||
@@ -61,7 +60,7 @@ authorization from the copyright holder.
|
||||
#define SYNCTEX_OS2 1
|
||||
#endif
|
||||
|
||||
-#ifdef _WIN32_WINNT_WINXP
|
||||
+#if defined(_WIN32)
|
||||
#define SYNCTEX_RECENT_WINDOWS 1
|
||||
#endif
|
||||
|
||||
@@ -71,18 +70,25 @@ authorization from the copyright holder.
|
||||
#endif
|
||||
|
||||
void *_synctex_malloc(size_t size) {
|
||||
- void * ptr = malloc(size);
|
||||
- if(ptr) {
|
||||
-/* There used to be a switch to use bzero because it is more secure. JL */
|
||||
- memset(ptr,0, size);
|
||||
- }
|
||||
- return (void *)ptr;
|
||||
+ void * ptr = malloc(size);
|
||||
+ if(ptr) {
|
||||
+ memset(ptr,0, size);/* ensures null termination of strings */
|
||||
+ }
|
||||
+ return (void *)ptr;
|
||||
}
|
||||
|
||||
-int _synctex_error(const char * reason,...) {
|
||||
- va_list arg;
|
||||
+void _synctex_free(void * ptr) {
|
||||
+ if (ptr) {
|
||||
+ free(ptr);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#if !defined(_WIN32)
|
||||
+# include <syslog.h>
|
||||
+#endif
|
||||
+
|
||||
+int _synctex_log(int level, const char * prompt, const char * reason,va_list arg) {
|
||||
int result;
|
||||
- va_start (arg, reason);
|
||||
# ifdef SYNCTEX_RECENT_WINDOWS
|
||||
{/* This code is contributed by William Blum.
|
||||
As it does not work on some older computers,
|
||||
@@ -94,23 +100,65 @@ int _synctex_error(const char * reason,...) {
|
||||
JL.*/
|
||||
char *buff;
|
||||
size_t len;
|
||||
- OutputDebugStringA("SyncTeX ERROR: ");
|
||||
+ OutputDebugStringA(prompt);
|
||||
len = _vscprintf(reason, arg) + 1;
|
||||
buff = (char*)malloc( len * sizeof(char) );
|
||||
- result = vsprintf(buff, reason, arg) +strlen("SyncTeX ERROR: ");
|
||||
+ result = vsprintf(buff, reason, arg) +strlen(prompt);
|
||||
OutputDebugStringA(buff);
|
||||
OutputDebugStringA("\n");
|
||||
free(buff);
|
||||
}
|
||||
+# elif SYNCTEX_USE_SYSLOG
|
||||
+ char * buffer1 = NULL;
|
||||
+ char * buffer2 = NULL;
|
||||
+ openlog ("SyncTeX", LOG_CONS | LOG_PID | LOG_PERROR | LOG_NDELAY, LOG_LOCAL0);
|
||||
+ if (vasprintf(&buffer1,reason,arg)>=0
|
||||
+ && asprintf(&buffer2,"%s%s",prompt, buffer1)>=0) {
|
||||
+ syslog (level, "%s", buffer2);
|
||||
+ result = (int)strlen(buffer2);
|
||||
+ } else {
|
||||
+ syslog (level, "%s",prompt);
|
||||
+ vsyslog(level,reason,arg);
|
||||
+ result = (int)strlen(prompt);
|
||||
+ }
|
||||
+ free(buffer1);
|
||||
+ free(buffer2);
|
||||
+ closelog();
|
||||
# else
|
||||
- result = fprintf(stderr,"SyncTeX ERROR: ");
|
||||
- result += vfprintf(stderr, reason, arg);
|
||||
- result += fprintf(stderr,"\n");
|
||||
+ FILE * where = level == LOG_ERR? stderr: stdout;
|
||||
+ result = fputs(prompt,where);
|
||||
+ result += vfprintf(where, reason, arg);
|
||||
+ result += fprintf(where,"\n");
|
||||
# endif
|
||||
- va_end (arg);
|
||||
return result;
|
||||
}
|
||||
|
||||
+int _synctex_error(const char * reason,...) {
|
||||
+ va_list arg;
|
||||
+ int result;
|
||||
+ va_start (arg, reason);
|
||||
+#if defined(SYNCTEX_RECENT_WINDOWS) /* LOG_ERR is not used */
|
||||
+ result = _synctex_log(0, "! SyncTeX Error : ", reason, arg);
|
||||
+#else
|
||||
+ result = _synctex_log(LOG_ERR, "! SyncTeX Error : ", reason, arg);
|
||||
+#endif
|
||||
+ va_end (arg);
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+int _synctex_debug(const char * reason,...) {
|
||||
+ va_list arg;
|
||||
+ int result;
|
||||
+ va_start (arg, reason);
|
||||
+#if defined(SYNCTEX_RECENT_WINDOWS) /* LOG_DEBUG is not used */
|
||||
+ result = _synctex_log(0, "! SyncTeX Error : ", reason, arg);
|
||||
+#else
|
||||
+ result = _synctex_log(LOG_DEBUG, "! SyncTeX Error : ", reason, arg);
|
||||
+#endif
|
||||
+ va_end (arg);
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
/* strip the last extension of the given string, this string is modified! */
|
||||
void _synctex_strip_last_path_extension(char * string) {
|
||||
if(NULL != string){
|
||||
@@ -250,8 +298,8 @@ const char * _synctex_last_path_component(const char *
|
||||
}
|
||||
|
||||
int _synctex_copy_with_quoting_last_path_component(const char * src, char ** dest_ref, size_t size) {
|
||||
- const char * lpc;
|
||||
if(src && dest_ref) {
|
||||
+ const char * lpc;
|
||||
# define dest (*dest_ref)
|
||||
dest = NULL; /* Default behavior: no change and sucess. */
|
||||
lpc = _synctex_last_path_component(src);
|
||||
@@ -396,7 +444,6 @@ int _synctex_get_name(const char * output, const char
|
||||
if(NULL == (dir_name = (char *)malloc(size+1))) {
|
||||
_synctex_error("! _synctex_get_name: Memory problem");
|
||||
free(core_name);
|
||||
- dir_name = NULL;
|
||||
return -1;
|
||||
}
|
||||
if(dir_name != strncpy(dir_name,output,size)) {
|
||||
@@ -497,6 +544,17 @@ int _synctex_get_name(const char * output, const char
|
||||
# undef CLEAN_AND_REMOVE
|
||||
/* set up the returned values */
|
||||
* synctex_name_ref = synctex_name;
|
||||
+ /* synctex_name won't always end in .gz, even when compressed. */
|
||||
+ FILE * F = fopen(synctex_name, "r");
|
||||
+ if (F != NULL) {
|
||||
+ if (!feof(F)
|
||||
+ && 31 == fgetc(F)
|
||||
+ && !feof(F)
|
||||
+ && 139 == fgetc(F)) {
|
||||
+ io_mode = synctex_compress_mode_gz;
|
||||
+ }
|
||||
+ fclose(F);
|
||||
+ }
|
||||
* io_mode_ref = io_mode;
|
||||
return 0;
|
||||
}
|
81
editors/texworks/patches/patch-src_synctex_parser_utils_h
Normal file
81
editors/texworks/patches/patch-src_synctex_parser_utils_h
Normal file
@ -0,0 +1,81 @@
|
||||
$OpenBSD: patch-src_synctex_parser_utils_h,v 1.1 2019/01/20 11:20:45 edd Exp $
|
||||
|
||||
Make texworks build against a newer synctex:
|
||||
https://github.com/TeXworks/texworks/commit/496cc1785f335f0eb4451005025fe11ae295d3e4
|
||||
|
||||
Index: src/synctex_parser_utils.h
|
||||
--- src/synctex_parser_utils.h.orig
|
||||
+++ src/synctex_parser_utils.h
|
||||
@@ -1,16 +1,15 @@
|
||||
/*
|
||||
-Copyright (c) 2008, 2009, 2010, 2011 jerome DOT laurens AT u-bourgogne DOT fr
|
||||
+ Copyright (c) 2008-2017 jerome DOT laurens AT u-bourgogne DOT fr
|
||||
+
|
||||
+ This file is part of the __SyncTeX__ package.
|
||||
+
|
||||
+ [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017)
|
||||
+ [//]: # (Version: 1.19)
|
||||
+
|
||||
+ See `synctex_parser_readme.md` for more details
|
||||
+
|
||||
+ ## License
|
||||
|
||||
-This file is part of the SyncTeX package.
|
||||
-
|
||||
-Latest Revision: Tue Jun 14 08:23:30 UTC 2011
|
||||
-
|
||||
-Version: 1.18
|
||||
-
|
||||
-See synctex_parser_readme.txt for more details
|
||||
-
|
||||
-License:
|
||||
---------
|
||||
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
|
||||
@@ -39,16 +38,20 @@ authorization from the copyright holder.
|
||||
|
||||
*/
|
||||
|
||||
+#ifndef SYNCTEX_PARSER_UTILS_H
|
||||
+#define SYNCTEX_PARSER_UTILS_H
|
||||
+
|
||||
/* The utilities declared here are subject to conditional implementation.
|
||||
* All the operating system special stuff goes here.
|
||||
* The problem mainly comes from file name management: path separator, encoding...
|
||||
*/
|
||||
|
||||
-# define synctex_bool_t int
|
||||
-# define synctex_YES -1
|
||||
+typedef int synctex_bool_t;
|
||||
+# define synctex_YES (0==0)
|
||||
+# define synctex_NO (0==1)
|
||||
+
|
||||
# define synctex_ADD_QUOTES -1
|
||||
# define synctex_COMPRESS -1
|
||||
-# define synctex_NO 0
|
||||
# define synctex_DONT_ADD_QUOTES 0
|
||||
# define synctex_DONT_COMPRESS 0
|
||||
|
||||
@@ -85,10 +88,15 @@ extern "C" {
|
||||
* There is no bzero function on windows. */
|
||||
void *_synctex_malloc(size_t size);
|
||||
|
||||
+/* To balance _synctex_malloc.
|
||||
+ * ptr might be NULL. */
|
||||
+void _synctex_free(void * ptr);
|
||||
+
|
||||
/* This is used to log some informational message to the standard error stream.
|
||||
* On Windows, the stderr stream is not exposed and another method is used.
|
||||
* The return value is the number of characters printed. */
|
||||
-int _synctex_error(const char * reason,...);
|
||||
+ int _synctex_error(const char * reason,...);
|
||||
+ int _synctex_debug(const char * reason,...);
|
||||
|
||||
/* strip the last extension of the given string, this string is modified!
|
||||
* This function depends on the OS because the path separator may differ.
|
||||
@@ -150,3 +158,4 @@ synctex_bool_t synctex_ignore_leading_dot_slash_in_pat
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+#endif /* SYNCTEX_PARSER_UTILS_H */
|
Loading…
x
Reference in New Issue
Block a user