[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[texworks] 30/73: Imported Upstream version 0.5~svn952



This is an automated email from the git hooks/post-receive script.

preining pushed a commit to branch master
in repository texworks.

commit ef744bbd938d5a05c2316d500533be477def7b0f
Author: Atsuhito KOHDA <kohda@debian.org>
Date:   Mon Dec 12 15:44:20 2011 +0900

    Imported Upstream version 0.5~svn952
---
 CMake/Modules/FindPoppler.cmake                    |   8 +-
 CMake/packaging/mac/MacPackagingTasks.cmake.in     |  12 +-
 CMake/packaging/mac/poppler.rb                     |  32 +-
 TeXworks.plist                                     |  72 --
 ...pler-fix-cmake-install-names-for-homebrew.patch |  10 +-
 src/PDFDocument.cpp                                |   5 +
 src/PrefsDialog.cpp                                |  13 +-
 src/PrefsDialog.h                                  |   1 +
 src/PrefsDialog.ui                                 |  14 +-
 src/SvnRev.h                                       |   4 +-
 src/TWApp.cpp                                      |   8 +-
 src/TWScript.h                                     |   8 +-
 src/TWScriptable.cpp                               |   2 +-
 src/TWUtils.cpp                                    |   3 +-
 src/TeXDocument.cpp                                |   8 +-
 src/synctex_parser.c                               | 910 ++++++++++++---------
 src/synctex_parser.h                               |  16 +-
 src/synctex_parser_utils.c                         |  64 +-
 src/synctex_parser_utils.h                         |  18 +-
 src/synctex_parser_version.txt                     |   2 +-
 20 files changed, 702 insertions(+), 508 deletions(-)

diff --git a/CMake/Modules/FindPoppler.cmake b/CMake/Modules/FindPoppler.cmake
index a34a932..9b9669c 100644
--- a/CMake/Modules/FindPoppler.cmake
+++ b/CMake/Modules/FindPoppler.cmake
@@ -36,7 +36,8 @@ FIND_PATH(POPPLER_XPDF_INCLUDE_DIR NAMES poppler-config.h
     /usr/include
   HINTS
     ${POPPLER_PKG_INCLUDE_DIRS} # Generated by pkg-config
-  PATH_SUFFIXES poppler
+  PATH_SUFFIXES
+    poppler
 )
 
 IF( NOT(POPPLER_XPDF_INCLUDE_DIR) )
@@ -83,7 +84,10 @@ FIND_PATH(POPPLER_QT4_INCLUDE_DIR NAMES poppler-qt4.h poppler-link.h
     /usr/include
   HINTS
     ${POPPLER_QT4_PKG_INCLUDE_DIRS} # Generated by pkg-config
-  PATH_SUFFIXES poppler qt4
+  PATH_SUFFIXES
+    poppler
+    qt4
+    poppler/qt4
 )
 IF ( NOT(POPPLER_QT4_INCLUDE_DIR) )
   MESSAGE(STATUS "Could not find Poppler-Qt4 headers." )
diff --git a/CMake/packaging/mac/MacPackagingTasks.cmake.in b/CMake/packaging/mac/MacPackagingTasks.cmake.in
index 39b3a3a..fe904c8 100644
--- a/CMake/packaging/mac/MacPackagingTasks.cmake.in
+++ b/CMake/packaging/mac/MacPackagingTasks.cmake.in
@@ -18,20 +18,20 @@ IF ( ${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.* )
   # ---------------------------------
   IF ( NOT EXISTS ${PROJECT_SOURCE_DIR}/poppler-data-0.4.4.tar.gz )
     MESSAGE(STATUS "Downloading Poppler data files")
-    FILE(DOWNLOAD "http://poppler.freedesktop.org/poppler-data-0.4.4.tar.gz";
-      ${PROJECT_SOURCE_DIR}/poppler-data-0.4.4.tar.gz
-      EXPECTED_MD5 f3a1afa9218386b50ffd262c00b35b31
+    FILE(DOWNLOAD "http://poppler.freedesktop.org/poppler-data-0.4.5.tar.gz";
+      ${PROJECT_SOURCE_DIR}/poppler-data-0.4.5.tar.gz
+      EXPECTED_MD5 448dd7c5077570e340340706cef931aa
       SHOW_PROGRESS
     )
   ENDIF ()
 
-  IF ( NOT EXISTS ${PROJECT_SOURCE_DIR}/poppler-data-0.4.4 )
-    EXECUTE_PROCESS(COMMAND tar xzf ${PROJECT_SOURCE_DIR}/poppler-data-0.4.4.tar.gz
+  IF ( NOT EXISTS ${PROJECT_SOURCE_DIR}/poppler-data-0.4.5 )
+    EXECUTE_PROCESS(COMMAND tar xzf ${PROJECT_SOURCE_DIR}/poppler-data-0.4.5.tar.gz
       WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
     )
   ENDIF ()
 
-  FILE(INSTALL ${PROJECT_SOURCE_DIR}/poppler-data-0.4.4/
+  FILE(INSTALL ${PROJECT_SOURCE_DIR}/poppler-data-0.4.5/
     DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/poppler-data
     PATTERN CMakeLists.txt EXCLUDE
     PATTERN Makefile EXCLUDE
diff --git a/CMake/packaging/mac/poppler.rb b/CMake/packaging/mac/poppler.rb
index 822dd39..598a8ff 100644
--- a/CMake/packaging/mac/poppler.rb
+++ b/CMake/packaging/mac/poppler.rb
@@ -5,7 +5,7 @@
 #
 # To install Poppler using this formula:
 #
-#     brew install --with-qt4 --enable-xpdf-headers path/to/this/poppler.rb
+#     brew install path/to/this/poppler.rb
 #
 # Changes compared to Homebrew's standard Poppler formula:
 #
@@ -21,17 +21,18 @@ TEXWORKS_PATCH_DIR = TEXWORKS_SOURCE_DIR + 'lib-patches'
 require 'formula'
 
 class PopplerData < Formula
-  url 'http://poppler.freedesktop.org/poppler-data-0.4.4.tar.gz'
-  md5 'f3a1afa9218386b50ffd262c00b35b31'
+  url 'http://poppler.freedesktop.org/poppler-data-0.4.5.tar.gz'
+  md5 '448dd7c5077570e340340706cef931aa'
 end
 
 class Poppler < Formula
-  url 'http://poppler.freedesktop.org/poppler-0.16.7.tar.gz'
-  homepage 'http://poppler.freedesktop.org/'
-  md5 '3afa28e3c8c4f06b0fbca3c91e06394e'
+  url 'http://poppler.freedesktop.org/poppler-0.18.1.tar.gz'
+  homepage 'http://poppler.freedesktop.org'
+  md5 'd30e883a27423c936ef338ce1d967e2d'
+  version '0.18.1-texworks'
 
   depends_on 'pkg-config' => :build
-  depends_on "qt" if ARGV.include? "--with-qt4"
+  depends_on 'qt'
 
   def patches
     {
@@ -43,14 +44,8 @@ class Poppler < Formula
     }
   end
 
-  def options
-    [
-      ["--with-qt4", "Include Qt4 support (which compiles all of Qt4!)"],
-      ["--enable-xpdf-headers", "Also install XPDF headers."]
-    ]
-  end
-
   def install
+    ENV.x11
     cmake_args = std_cmake_parameters.split
 
     # Save time by not building tests
@@ -61,10 +56,13 @@ class Poppler < Formula
       '-DBUILD_QT4_TESTS=OFF'
     ]
 
-    cmake_args << "-DWITH_Qt4=OFF" unless ARGV.include? "--with-qt4"
-    cmake_args << "-DENABLE_XPDF_HEADERS=ON" if ARGV.include? "--enable-xpdf-headers"
+    # Components required by TeXworks.
+    cmake_args.concat [
+      '-DWITH_Qt4=YES',
+      '-DENABLE_XPDF_HEADERS=YES'
+    ]
 
-    # TeXworks-specific additions to minimize library dependencies
+    # Minimize library dependencies for TeXworks
     cmake_args.concat [
       '-DENABLE_ABIWORD=OFF',
       '-DENABLE_CPP=OFF',
diff --git a/TeXworks.plist b/TeXworks.plist
deleted file mode 100644
index 63944b5..0000000
--- a/TeXworks.plist
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE plist PUBLIC
-	"-//Apple Computer//DTD PLIST 1.0//EN"
-	"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
-<plist version="1.0">
-<dict>
-	<key>CFBundleDocumentTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>tex</string>
-				<string>ltx</string>
-				<string>sty</string>
-				<string>cls</string>
-				<string>dtx</string>
-			</array>
-			<key>CFBundleTypeIconFile</key>
-			<string>TeXworks-doc.icns</string>
-			<key>CFBundleTypeMIMETypes</key>
-			<array>
-				<string>text/plain</string>
-			</array>
-			<key>CFBundleTypeName</key>
-			<string>TeX Document</string>
-			<key>CFBundleTypeRole</key>
-			<string>Editor</string>
-			<key>LSIsAppleDefaultForType</key>
-			<true/>
-		</dict>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>pdf</string>
-			</array>
-			<key>CFBundleTypeIconFile</key>
-			<string>TeXworks-doc.icns</string>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-			<key>CFBundleTypeMIMETypes</key>
-			<array>
-				<string>application/pdf</string>
-			</array>
-			<key>LSItemContentTypes</key>
-			<array>
-				<string>com.adobe.pdf</string>
-			</array>
-			<key>CFBundleTypeName</key>
-			<string>PDF Document</string>
-		</dict>
-	</array>
-	<key>CFBundleIconFile</key>
-	<string>TeXworks.icns</string>
-	<key>CFBundleGetInfoString</key>
-	<string>TeXworks version 0.5 (r.939)&#xA;(C) 2007-2011 Jonathan Kew, Stefan L&#xF6;ffler&#xA;Released under GPL (v2.0 or later)</string>
-	<key>CFBundleExecutable</key>
-	<string>TeXworks</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.tug.texworks</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleShortVersionString</key>
-	<string>0.5 (r.939)</string>
-	<key>CFBundleVersion</key>
-	<string>0.5 (r.939)</string>
-	<key>CSResourcesFileMapped</key>
-	<true/>
-</dict>
-</plist>
diff --git a/lib-patches/poppler-fix-cmake-install-names-for-homebrew.patch b/lib-patches/poppler-fix-cmake-install-names-for-homebrew.patch
index babd1d4..f12330f 100644
--- a/lib-patches/poppler-fix-cmake-install-names-for-homebrew.patch
+++ b/lib-patches/poppler-fix-cmake-install-names-for-homebrew.patch
@@ -1,25 +1,25 @@
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index f144ddf..54c9ceb 100644
+index 5614238..dbcf436 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -377,7 +377,7 @@ add_library(poppler STATIC ${poppler_SRCS})
+@@ -351,7 +351,7 @@ add_library(poppler STATIC ${poppler_SRCS})
  else(MSVC)
  add_library(poppler SHARED ${poppler_SRCS})
  endif(MSVC)
--set_target_properties(poppler PROPERTIES VERSION 13.0.0 SOVERSION 13)
+-set_target_properties(poppler PROPERTIES VERSION 19.0.0 SOVERSION 19)
 +set_target_properties(poppler PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
  target_link_libraries(poppler ${poppler_LIBS})
  target_link_libraries(poppler LINK_INTERFACE_LIBRARIES "")
  install(TARGETS poppler RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX})
 diff --git a/qt4/src/CMakeLists.txt b/qt4/src/CMakeLists.txt
-index 479e6ad..7d06a9d 100644
+index 8ce8ff4..7d06a9d 100644
 --- a/qt4/src/CMakeLists.txt
 +++ b/qt4/src/CMakeLists.txt
 @@ -29,7 +29,7 @@ set(poppler_qt4_SRCS
  )
  qt4_automoc(${poppler_qt4_SRCS})
  add_library(poppler-qt4 SHARED ${poppler_qt4_SRCS})
--set_target_properties(poppler-qt4 PROPERTIES VERSION 3.4.0 SOVERSION 3)
+-set_target_properties(poppler-qt4 PROPERTIES VERSION 3.7.0 SOVERSION 3)
 +set_target_properties(poppler-qt4 PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
  target_link_libraries(poppler-qt4 poppler ${QT4_QTCORE_LIBRARY} ${QT4_QTGUI_LIBRARY} ${QT4_QTXML_LIBRARY})
  if(MSVC)
diff --git a/src/PDFDocument.cpp b/src/PDFDocument.cpp
index 4db61ee..57f62b0 100644
--- a/src/PDFDocument.cpp
+++ b/src/PDFDocument.cpp
@@ -1099,6 +1099,7 @@ QScrollArea* PDFWidget::getScrollArea()
 
 #pragma mark === PDFDocument ===
 
+// TODO: This is seemingly unused---verify && remove
 QList<PDFDocument*> PDFDocument::docList;
 
 PDFDocument::PDFDocument(const QString &fileName, TeXDocument *texDoc)
@@ -1382,6 +1383,10 @@ void PDFDocument::saveRecentFileInfo()
 void PDFDocument::loadFile(const QString &fileName)
 {
 	setCurrentFile(fileName);
+	QSETTINGS_OBJECT(settings);
+	QFileInfo info(fileName);
+	settings.setValue("openDialogDir", info.canonicalPath());
+
 	reload();
 	if (watcher) {
 		const QStringList files = watcher->files();
diff --git a/src/PrefsDialog.cpp b/src/PrefsDialog.cpp
index 95870d8..bacee85 100644
--- a/src/PrefsDialog.cpp
+++ b/src/PrefsDialog.cpp
@@ -133,8 +133,9 @@ void PrefsDialog::movePathDown()
 void PrefsDialog::addPath()
 {
 	QString dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"),
-					 "/usr", 0 /*QFileDialog::DontUseNativeDialog*/
-								/*QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks*/);
+					 "/usr", /*0*/ /*QFileDialog::DontUseNativeDialog*/
+								QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+	// remove the trailing / (if any)
 	dir = QDir::fromNativeSeparators(dir);
 #ifdef Q_WS_WIN
 	if (dir.length() > 2)
@@ -317,6 +318,7 @@ void PrefsDialog::restoreDefaults()
 			smartQuotes->setCurrentIndex(kDefault_QuotesMode);
 			encoding->setCurrentIndex(encoding->findText("UTF-8"));
 			highlightCurrentLine->setChecked(kDefault_HighlightCurrentLine);
+			autocompleteEnabled->setChecked(kDefault_AutocompleteEnabled);
 			break;
 	
 		case 2:
@@ -525,6 +527,7 @@ QDialog::DialogCode PrefsDialog::doPrefsDialog(QWidget *parent)
 	dlg.fontSize->setValue(font.pointSize());
 	dlg.encoding->setCurrentIndex(nameList.indexOf(TWApp::instance()->getDefaultCodec()->name()));
 	dlg.highlightCurrentLine->setChecked(settings.value("highlightCurrentLine", kDefault_HighlightCurrentLine).toBool());
+	dlg.autocompleteEnabled->setChecked(settings.value("autocompleteEnabled", kDefault_AutocompleteEnabled).toBool());
 
 	QString defDict = settings.value("language", "None").toString();
 	int i = dlg.language->findData(defDict);
@@ -672,7 +675,11 @@ QDialog::DialogCode PrefsDialog::doPrefsDialog(QWidget *parent)
 		bool highlightLine = dlg.highlightCurrentLine->isChecked();
 		settings.setValue("highlightCurrentLine", highlightLine);
 		CompletingEdit::setHighlightCurrentLine(highlightLine);
-		
+
+		bool autocompleteEnabled = dlg.autocompleteEnabled->isChecked();
+		settings.setValue("autocompleteEnabled", autocompleteEnabled);
+		CompletingEdit::setAutocompleteEnabled(autocompleteEnabled);
+
 		// Since the tab width can't be set by any other means, forcibly update
 		// all windows now
 		foreach (QWidget* widget, TWApp::instance()->allWidgets()) {
diff --git a/src/PrefsDialog.h b/src/PrefsDialog.h
index 1a525c4..127bc28 100644
--- a/src/PrefsDialog.h
+++ b/src/PrefsDialog.h
@@ -41,6 +41,7 @@ const bool kDefault_WrapLines = true;
 const int kDefault_TabWidth = 32;
 const int kDefault_HideConsole = 1;
 const bool kDefault_HighlightCurrentLine = true;
+const bool kDefault_AutocompleteEnabled = true;
 
 class QListWidgetItem;
 
diff --git a/src/PrefsDialog.ui b/src/PrefsDialog.ui
index 8a151c1..5993098 100644
--- a/src/PrefsDialog.ui
+++ b/src/PrefsDialog.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>541</width>
-    <height>511</height>
+    <width>676</width>
+    <height>534</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -496,6 +496,16 @@
             </property>
            </widget>
           </item>
+          <item row="1" column="0">
+           <widget class="QCheckBox" name="autocompleteEnabled">
+            <property name="text">
+             <string>Enable autocompletion</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>
diff --git a/src/SvnRev.h b/src/SvnRev.h
index 8d790a1..ced8263 100644
--- a/src/SvnRev.h
+++ b/src/SvnRev.h
@@ -1,2 +1,2 @@
-#define SVN_REVISION 939
-#define SVN_REVISION_STR "939"
+#define SVN_REVISION 952
+#define SVN_REVISION_STR "952"
diff --git a/src/TWApp.cpp b/src/TWApp.cpp
index 2a56c10..227fdd8 100644
--- a/src/TWApp.cpp
+++ b/src/TWApp.cpp
@@ -475,7 +475,7 @@ void TWApp::writeToMailingList()
 {
 	// The strings here are deliberately NOT localizable!
 	QString address("texworks@tug.org");
-	QString body("Instructions:\n-) Please write your message in English (it's in your own best interest; otherwise, many people will not be able to understand it and therefore will not answer).\n\n-) Please type something meaningful in the subject line.\n\n-) If you are having a problem, please describe it step-by-step in detail.\n\n-) After reading, please delete these instructions (up to the \"configuration info\" below which we may need to find the source of problems).\n\n\n\n----- conf [...]
+	QString body("Thank you for taking the time to write an email to the TeXworks mailing list. Please read the instructions below carefully as following them will greatly facilitate the communication.\n\nInstructions:\n-) Please write your message in English (it's in your own best interest; otherwise, many people will not be able to understand it and therefore will not answer).\n\n-) Please type something meaningful in the subject line.\n\n-) If you are having a problem, please describe it [...]
 
 	body += "TeXworks version : " TEXWORKS_VERSION "r" SVN_REVISION_STR " (" TW_BUILD_ID_STR ")\n";
 #ifdef Q_WS_MAC
@@ -529,7 +529,11 @@ void TWApp::writeToMailingList()
 	body += " (runtime)\n";
 	body += "------------------------------\n";
 
-	openUrl(QUrl(QString("mailto:%1?&body=%3";).arg(address).arg(body)));
+#ifdef Q_WS_WIN
+	body.replace('\n', "\r\n");
+#endif
+
+	openUrl(QUrl(QString("mailto:%1?subject=&body=%2";).arg(address).arg(body)));
 }
 
 void TWApp::launchAction()
diff --git a/src/TWScript.h b/src/TWScript.h
index aa523ad..545f68d 100644
--- a/src/TWScript.h
+++ b/src/TWScript.h
@@ -50,7 +50,13 @@ public:
 		ScriptHook,			///< hook, i.e. a script that is called automatically when the execution reaches a certain point
 		ScriptStandalone	///< standalone script, i.e. one that can be invoked by the user
 	};
-	
+
+	Q_PROPERTY(QString fileName READ getFilename);
+	Q_PROPERTY(QString title READ getTitle);
+	Q_PROPERTY(QString description READ getDescription);
+	Q_PROPERTY(QString author READ getAuthor);
+	Q_PROPERTY(QString version READ getVersion);
+
 	/** \brief	Destructor
 	 *
 	 * Does nothing
diff --git a/src/TWScriptable.cpp b/src/TWScriptable.cpp
index f5bd5a4..2a14e24 100644
--- a/src/TWScriptable.cpp
+++ b/src/TWScriptable.cpp
@@ -567,7 +567,7 @@ TWScriptable::runScript(QObject* script, TWScript::ScriptType scriptType)
 	bool success = sm->runScript(script, this, result, scriptType);
 
 	if (success) {
-		if (!result.isNull()) {
+		if (!result.isNull() and !result.toString().isEmpty()) {
 			if (scriptType == TWScript::ScriptHook)
 				statusBar()->showMessage(tr("Script \"%1\": %2").arg(s->getTitle()).arg(result.toString()), kStatusMessageDuration);
 			else
diff --git a/src/TWUtils.cpp b/src/TWUtils.cpp
index 2709d17..3ec397d 100644
--- a/src/TWUtils.cpp
+++ b/src/TWUtils.cpp
@@ -453,11 +453,12 @@ void TWUtils::setDefaultFilters()
 {
 	*filters << QObject::tr("TeX documents (*.tex)");
 	*filters << QObject::tr("LaTeX documents (*.ltx)");
+	*filters << QObject::tr("Log files (*.log)");
 	*filters << QObject::tr("BibTeX databases (*.bib)");
 	*filters << QObject::tr("Style files (*.sty)");
 	*filters << QObject::tr("Class files (*.cls)");
 	*filters << QObject::tr("Documented macros (*.dtx)");
-	*filters << QObject::tr("Auxiliary files (*.aux *.toc *.lot *.lof *.nav *.out *.snm *.ind *.idx *.bbl *.log)");
+	*filters << QObject::tr("Auxiliary files (*.aux *.toc *.lot *.lof *.nav *.out *.snm *.ind *.idx *.bbl)");
 	*filters << QObject::tr("Text files (*.txt)");
 	*filters << QObject::tr("PDF documents (*.pdf)");
 	*filters << QObject::tr("All files") + " (*)"; // this must not be "*.*", which causes an extension ".*" to be added on some systems
diff --git a/src/TeXDocument.cpp b/src/TeXDocument.cpp
index b441d39..550cf60 100644
--- a/src/TeXDocument.cpp
+++ b/src/TeXDocument.cpp
@@ -568,8 +568,6 @@ void TeXDocument::open()
 	QStringList files = QFileDialog::getOpenFileNames(this, QString(tr("Open File")), lastOpenDir, TWUtils::filterList()->join(";;"), NULL, options);
 	foreach (QString fileName, files) {
 		if (!fileName.isEmpty()) {
-			QFileInfo info(fileName);
-			settings.setValue("openDialogDir", info.canonicalPath());
 			TWApp::instance()->openFile(fileName); // not TeXDocument::open() - give the app a chance to open as PDF
 		}
 	}
@@ -1025,6 +1023,12 @@ void TeXDocument::loadFile(const QString &fileName, bool asTemplate, bool inBack
 		if (!inBackground) {
 			openPdfIfAvailable(false);
 		}
+		// set openDialogDir after openPdfIfAvailable as we want the .tex file's
+		// path to end up in that variable (which might be touched/changed when
+		// loading the pdf
+		QSETTINGS_OBJECT(settings);
+		QFileInfo info(fileName);
+		settings.setValue("openDialogDir", info.canonicalPath());
 
 		statusBar()->showMessage(tr("File \"%1\" loaded").arg(TWUtils::strippedName(curFile)),
 								 kStatusMessageDuration);
diff --git a/src/synctex_parser.c b/src/synctex_parser.c
index 0d3de08..508db2e 100644
--- a/src/synctex_parser.c
+++ b/src/synctex_parser.c
@@ -5,7 +5,7 @@ This file is part of the SyncTeX package.
 
 Latest Revision: Tue Jun 14 08:23:30 UTC 2011
 
-Version: 1.16
+Version: 1.17
 
 See synctex_parser_readme.txt for more details
 
@@ -118,7 +118,22 @@ typedef union _synctex_info_t {
 	char * PTR;
 } synctex_info_t;
 
+#   if defined(SYNCTEX_USE_CHARINDEX)
+#       define SYNCTEX_DECLARE_CHARINDEX synctex_charindex_t char_index
+#       define SYNCTEX_CHARINDEX(NODE) (NODE->char_index)
+#       define SYNCTEX_PRINT_CHARINDEX printf("#%i\n",SYNCTEX_CHARINDEX(node))
+#       define SYNCTEX_DECLARE_CHAR_OFFSET synctex_charindex_t charindex_offset
+#       define SYNCTEX_IMPLEMENT_CHARINDEX(NODE,CORRECTION) NODE->char_index = (synctex_charindex_t)(scanner->charindex_offset+SYNCTEX_CUR-SYNCTEX_START+(CORRECTION));
+#   else
+#       define SYNCTEX_DECLARE_CHARINDEX
+#       define SYNCTEX_CHARINDEX(NODE) 0
+#       define SYNCTEX_PRINT_CHARINDEX printf("\n")
+#       define SYNCTEX_DECLARE_CHAR_OFFSET synctex_charindex_t charindex_offset
+#       define SYNCTEX_IMPLEMENT_CHARINDEX(NODE,CORRECTION)
+#   endif
+
 struct _synctex_node {
+    SYNCTEX_DECLARE_CHARINDEX;
 	synctex_class_t class;
 	synctex_info_t * implementation;
 };
@@ -151,7 +166,7 @@ struct __synctex_class_t {
 	_synctex_node_getter_t child;
 	_synctex_node_getter_t sibling;
 	_synctex_node_getter_t friend;
-	_synctex_node_getter_t next_box;
+	_synctex_node_getter_t next_hbox;
 	_synctex_info_getter_t info;
 };
 
@@ -220,9 +235,9 @@ struct __synctex_class_t {
 /*  Next box getter and setter. The box tree can be traversed from one horizontal box to the other.
  *  Navigation starts with the deeper boxes.
  */
-#   define SYNCTEX_NEXT_HORIZ_BOX(NODE) SYNCTEX_GET(NODE,next_box)
-#   define SYNCTEX_SET_NEXT_HORIZ_BOX(NODE,NEXT_BOX) if (NODE && NEXT_BOX){\
-		SYNCTEX_GETTER(NODE,next_box)[0]=NEXT_BOX;\
+#   define SYNCTEX_NEXT_hbox(NODE) SYNCTEX_GET(NODE,next_hbox)
+#   define SYNCTEX_SET_NEXT_hbox(NODE,NEXT_HBOX) if (NODE && NEXT_HBOX){\
+		SYNCTEX_GETTER(NODE,next_hbox)[0]=NEXT_HBOX;\
 	}
 
 void _synctex_free_node(synctex_node_t node);
@@ -245,6 +260,7 @@ void _synctex_free_node(synctex_node_t node) {
 /*  A node is meant to own its child and sibling.
  *  It is not owned by its parent, unless it is its first child.
  *  This destructor is for nodes with no child.
+ *  The first sheet is onwned by the scanner.
  */
 void _synctex_free_leaf(synctex_node_t node) {
 	if (node) {
@@ -265,6 +281,7 @@ void _synctex_free_leaf(synctex_node_t node) {
  */
 struct __synctex_scanner_t {
 	gzFile file;                  /*  The (possibly compressed) file */
+    SYNCTEX_DECLARE_CHAR_OFFSET;
 	char * buffer_cur;            /*  current location in the buffer */
 	char * buffer_start;          /*  start of the buffer */
 	char * buffer_end;            /*  end of the buffer */
@@ -340,14 +357,15 @@ SYNCTEX_MAKE_GET(_synctex_implementation_4,4)
 SYNCTEX_MAKE_GET(_synctex_implementation_5,5)
 
 typedef struct {
+    SYNCTEX_DECLARE_CHARINDEX;
 	synctex_class_t class;
 	synctex_info_t implementation[3+SYNCTEX_PAGE_IDX+1];/*  child, sibling, next box,
 	                         *  SYNCTEX_PAGE_IDX */
-} synctex_sheet_t;
+} synctex_node_sheet_t;
 
 synctex_node_t _synctex_new_sheet(synctex_scanner_t scanner);
-void _synctex_display_sheet(synctex_node_t sheet);
-void _synctex_log_sheet(synctex_node_t sheet);
+void _synctex_display_sheet(synctex_node_t node);
+void _synctex_log_sheet(synctex_node_t node);
 
 static _synctex_class_t synctex_class_sheet = {
 	NULL,                       /*  No scanner yet */
@@ -360,18 +378,26 @@ static _synctex_class_t synctex_class_sheet = {
 	&_synctex_implementation_0, /*  child */
 	&_synctex_implementation_1, /*  sibling */
 	NULL,                       /*  No friend */
-	&_synctex_implementation_2, /*  Next box */
+	&_synctex_implementation_2, /*  Next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_3  /*  info */
 };
 
 /*  sheet node creator */
-synctex_node_t _synctex_new_sheet(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_sheet_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_sheet:(synctex_class_t)&synctex_class_sheet;
-	}
-	return node;
+
+#define DEFINE_synctex_new_NODE(NAME)\
+synctex_node_t _synctex_new_##NAME(synctex_scanner_t scanner) {\
+	if (scanner) {\
+		synctex_node_t node = _synctex_malloc(sizeof(synctex_node_##NAME##_t));\
+		if (node) {\
+			SYNCTEX_IMPLEMENT_CHARINDEX(node,0);\
+			++SYNCTEX_CUR;\
+			node->class = scanner->class+synctex_node_type_##NAME;\
+		}\
+		return node;\
+	}\
+	return NULL;\
 }
+DEFINE_synctex_new_NODE(sheet)
 
 /*  A box node contains navigation and synctex information
  *  There are different kind of boxes.
@@ -399,14 +425,15 @@ synctex_node_t _synctex_new_sheet(synctex_scanner_t scanner) {
 #   define SYNCTEX_ABS_DEPTH(NODE) ((SYNCTEX_DEPTH(NODE)>0?SYNCTEX_DEPTH(NODE):-SYNCTEX_DEPTH(NODE)))
 
 typedef struct {
+    SYNCTEX_DECLARE_CHARINDEX;
 	synctex_class_t class;
 	synctex_info_t implementation[5+SYNCTEX_DEPTH_IDX+1]; /*  parent,child,sibling,friend,next box,
 						        *  SYNCTEX_TAG,SYNCTEX_LINE,SYNCTEX_COLUMN,
 								*  SYNCTEX_HORIZ,SYNCTEX_VERT,SYNCTEX_WIDTH,SYNCTEX_HEIGHT,SYNCTEX_DEPTH */
-} synctex_vert_box_node_t;
+} synctex_node_vbox_t;
 
 synctex_node_t _synctex_new_vbox(synctex_scanner_t scanner);
-void _synctex_log_box(synctex_node_t sheet);
+void _synctex_log_vbox(synctex_node_t node);
 void _synctex_display_vbox(synctex_node_t node);
 
 /*  These are static class objects, each scanner will make a copy of them and setup the scanner field.
@@ -416,31 +443,31 @@ static _synctex_class_t synctex_class_vbox = {
 	synctex_node_type_vbox,     /*  Node type */
 	&_synctex_new_vbox,         /*  creator */
 	&_synctex_free_node,        /*  destructor */
-	&_synctex_log_box,          /*  log */
+	&_synctex_log_vbox,          /*  log */
 	&_synctex_display_vbox,     /*  display */
 	&_synctex_implementation_0, /*  parent */
 	&_synctex_implementation_1, /*  child */
 	&_synctex_implementation_2, /*  sibling */
 	&_synctex_implementation_3, /*  friend */
-	&_synctex_implementation_4, /*  next box */
+	&_synctex_implementation_4, /*  next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_5
 };
 
 /*  vertical box node creator */
-synctex_node_t _synctex_new_vbox(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_vert_box_node_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_vbox:(synctex_class_t)&synctex_class_vbox;
-	}
-	return node;
-}
+DEFINE_synctex_new_NODE(vbox)
 
-#   define SYNCTEX_HORIZ_V_IDX (SYNCTEX_DEPTH_IDX+1)
+/*  Horizontal boxes must contain visible size, because 0 width does not mean emptiness.
+ *  They also contain an average of the line numbers of the containing nodes. */
+#   define SYNCTEX_MEAN_LINE_IDX (SYNCTEX_DEPTH_IDX+1)
+#   define SYNCTEX_NODE_WEIGHT_IDX (SYNCTEX_MEAN_LINE_IDX+1)
+#   define SYNCTEX_HORIZ_V_IDX (SYNCTEX_NODE_WEIGHT_IDX+1)
 #   define SYNCTEX_VERT_V_IDX (SYNCTEX_HORIZ_V_IDX+1)
 #   define SYNCTEX_WIDTH_V_IDX (SYNCTEX_VERT_V_IDX+1)
 #   define SYNCTEX_HEIGHT_V_IDX (SYNCTEX_WIDTH_V_IDX+1)
 #   define SYNCTEX_DEPTH_V_IDX (SYNCTEX_HEIGHT_V_IDX+1)
 /*  the corresponding info accessors */
+#   define SYNCTEX_MEAN_LINE(NODE) SYNCTEX_INFO(NODE)[SYNCTEX_MEAN_LINE_IDX].INT
+#   define SYNCTEX_NODE_WEIGHT(NODE) SYNCTEX_INFO(NODE)[SYNCTEX_NODE_WEIGHT_IDX].INT
 #   define SYNCTEX_HORIZ_V(NODE) SYNCTEX_INFO(NODE)[SYNCTEX_HORIZ_V_IDX].INT
 #   define SYNCTEX_VERT_V(NODE) SYNCTEX_INFO(NODE)[SYNCTEX_VERT_V_IDX].INT
 #   define SYNCTEX_WIDTH_V(NODE) SYNCTEX_INFO(NODE)[SYNCTEX_WIDTH_V_IDX].INT
@@ -450,18 +477,19 @@ synctex_node_t _synctex_new_vbox(synctex_scanner_t scanner) {
 #   define SYNCTEX_ABS_HEIGHT_V(NODE) ((SYNCTEX_HEIGHT_V(NODE)>0?SYNCTEX_HEIGHT_V(NODE):-SYNCTEX_HEIGHT_V(NODE)))
 #   define SYNCTEX_ABS_DEPTH_V(NODE) ((SYNCTEX_DEPTH_V(NODE)>0?SYNCTEX_DEPTH_V(NODE):-SYNCTEX_DEPTH_V(NODE)))
 
-/*  Horizontal boxes must contain visible size, because 0 width does not mean emptiness */
 typedef struct {
+    SYNCTEX_DECLARE_CHARINDEX;
 	synctex_class_t class;
 	synctex_info_t implementation[5+SYNCTEX_DEPTH_V_IDX+1]; /*parent,child,sibling,friend,next box,
 						*  SYNCTEX_TAG,SYNCTEX_LINE,SYNCTEX_COLUMN,
 						*  SYNCTEX_HORIZ,SYNCTEX_VERT,SYNCTEX_WIDTH,SYNCTEX_HEIGHT,SYNCTEX_DEPTH,
+                        *  SYNCTEX_MEAN_LINE,SYNCTEX_NODE_WEIGHT,
 						*  SYNCTEX_HORIZ_V,SYNCTEX_VERT_V,SYNCTEX_WIDTH_V,SYNCTEX_HEIGHT_V,SYNCTEX_DEPTH_V*/
-} synctex_horiz_box_node_t;
+} synctex_node_hbox_t;
 
 synctex_node_t _synctex_new_hbox(synctex_scanner_t scanner);
 void _synctex_display_hbox(synctex_node_t node);
-void _synctex_log_horiz_box(synctex_node_t sheet);
+void _synctex_log_hbox(synctex_node_t node);
 
 
 static _synctex_class_t synctex_class_hbox = {
@@ -469,37 +497,32 @@ static _synctex_class_t synctex_class_hbox = {
 	synctex_node_type_hbox,     /*  Node type */
 	&_synctex_new_hbox,         /*  creator */
 	&_synctex_free_node,        /*  destructor */
-	&_synctex_log_horiz_box,    /*  log */
+	&_synctex_log_hbox,    /*  log */
 	&_synctex_display_hbox,     /*  display */
 	&_synctex_implementation_0, /*  parent */
 	&_synctex_implementation_1, /*  child */
 	&_synctex_implementation_2, /*  sibling */
 	&_synctex_implementation_3, /*  friend */
-	&_synctex_implementation_4, /*  next box */
+	&_synctex_implementation_4, /*  next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_5
 };
 
 /*  horizontal box node creator */
-synctex_node_t _synctex_new_hbox(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_horiz_box_node_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_hbox:(synctex_class_t)&synctex_class_hbox;
-	}
-	return node;
-}
+DEFINE_synctex_new_NODE(hbox)
 
 /*  This void box node implementation is either horizontal or vertical
  *  It does not contain a child field.
  */
 typedef struct {
+    SYNCTEX_DECLARE_CHARINDEX;
 	synctex_class_t class;
 	synctex_info_t implementation[3+SYNCTEX_DEPTH_IDX+1]; /*  parent,sibling,friend,
 	                  *  SYNCTEX_TAG,SYNCTEX_LINE,SYNCTEX_COLUMN,
 					  *  SYNCTEX_HORIZ,SYNCTEX_VERT,SYNCTEX_WIDTH,SYNCTEX_HEIGHT,SYNCTEX_DEPTH*/
-} synctex_void_box_node_t;
+} synctex_node_void_vbox_t;
 
 synctex_node_t _synctex_new_void_vbox(synctex_scanner_t scanner);
-void _synctex_log_void_box(synctex_node_t sheet);
+void _synctex_log_void_box(synctex_node_t node);
 void _synctex_display_void_vbox(synctex_node_t node);
 
 static _synctex_class_t synctex_class_void_vbox = {
@@ -513,18 +536,14 @@ static _synctex_class_t synctex_class_void_vbox = {
 	NULL,                       /*  No child */
 	&_synctex_implementation_1, /*  sibling */
 	&_synctex_implementation_2, /*  friend */
-	NULL,						/*  No next box */
+	NULL,						/*  No next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_3
 };
 
 /*  vertical void box node creator */
-synctex_node_t _synctex_new_void_vbox(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_void_box_node_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_void_vbox:(synctex_class_t)&synctex_class_void_vbox;
-	}
-	return node;
-}
+DEFINE_synctex_new_NODE(void_vbox)
+
+typedef synctex_node_void_vbox_t synctex_node_void_hbox_t;
 
 synctex_node_t _synctex_new_void_hbox(synctex_scanner_t scanner);
 void _synctex_display_void_hbox(synctex_node_t node);
@@ -540,26 +559,22 @@ static _synctex_class_t synctex_class_void_hbox = {
 	NULL,                       /*  No child */
 	&_synctex_implementation_1, /*  sibling */
 	&_synctex_implementation_2, /*  friend */
-	NULL,						/*  No next box */
+	NULL,						/*  No next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_3
 };
 
 /*  horizontal void box node creator */
-synctex_node_t _synctex_new_void_hbox(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_void_box_node_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_void_hbox:(synctex_class_t)&synctex_class_void_hbox;
-	}
-	return node;
-}
+DEFINE_synctex_new_NODE(void_hbox)
 
-/*  The medium nodes correspond to kern, glue, penalty and math nodes.  */
+/*  The medium nodes correspond to kern, glue, penalty and math nodes.
+ *  In LuaTeX, the size of the nodes may have changed.  */
 typedef struct {
+    SYNCTEX_DECLARE_CHARINDEX;
 	synctex_class_t class;
 	synctex_info_t implementation[3+SYNCTEX_WIDTH_IDX+1]; /*  parent,sibling,friend,
 	                  *  SYNCTEX_TAG,SYNCTEX_LINE,SYNCTEX_COLUMN,
 					  *  SYNCTEX_HORIZ,SYNCTEX_VERT,SYNCTEX_WIDTH */
-} synctex_medium_node_t;
+} synctex_node_medium_t;
 
 #define SYNCTEX_IS_BOX(NODE)\
 	((NODE->class->type == synctex_node_type_vbox)\
@@ -571,6 +586,8 @@ typedef struct {
 	
 void _synctex_log_medium_node(synctex_node_t node);
 
+typedef synctex_node_medium_t synctex_node_math_t;
+
 /*  math node creator */
 synctex_node_t _synctex_new_math(synctex_scanner_t scanner);
 void _synctex_display_math(synctex_node_t node);
@@ -586,17 +603,13 @@ static _synctex_class_t synctex_class_math = {
 	NULL,                       /*  No child */
 	&_synctex_implementation_1, /*  sibling */
 	&_synctex_implementation_2, /*  friend */
-	NULL,                       /*  No next box */
+	NULL,                       /*  No next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_3
 };
 
-synctex_node_t _synctex_new_math(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_medium_node_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_math:(synctex_class_t)&synctex_class_math;
-	}
-	return node;
-}
+DEFINE_synctex_new_NODE(math)
+
+typedef synctex_node_medium_t synctex_node_kern_t;
 
 /*  kern node creator */
 synctex_node_t _synctex_new_kern(synctex_scanner_t scanner);
@@ -613,28 +626,25 @@ static _synctex_class_t synctex_class_kern = {
 	NULL,                       /*  No child */
 	&_synctex_implementation_1, /*  sibling */
 	&_synctex_implementation_2, /*  friend */
-	NULL,                       /*  No next box */
+	NULL,                       /*  No next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_3
 };
 
-synctex_node_t _synctex_new_kern(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_medium_node_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_kern:(synctex_class_t)&synctex_class_kern;
-	}
-	return node;
-}
+DEFINE_synctex_new_NODE(kern)
 
 /*  The small nodes correspond to glue and boundary nodes.  */
 typedef struct {
+    SYNCTEX_DECLARE_CHARINDEX;
 	synctex_class_t class;
 	synctex_info_t implementation[3+SYNCTEX_VERT_IDX+1]; /*  parent,sibling,friend,
 	                  *  SYNCTEX_TAG,SYNCTEX_LINE,SYNCTEX_COLUMN,
 					  *  SYNCTEX_HORIZ,SYNCTEX_VERT */
-} synctex_small_node_t;
+} synctex_node_small_t;
 
 void _synctex_log_small_node(synctex_node_t node);
+
 /*  glue node creator */
+typedef synctex_node_small_t synctex_node_glue_t;
 synctex_node_t _synctex_new_glue(synctex_scanner_t scanner);
 void _synctex_display_glue(synctex_node_t node);
 
@@ -649,18 +659,13 @@ static _synctex_class_t synctex_class_glue = {
 	NULL,                       /*  No child */
 	&_synctex_implementation_1, /*  sibling */
 	&_synctex_implementation_2, /*  friend */
-	NULL,                       /*  No next box */
+	NULL,                       /*  No next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_3
 };
-synctex_node_t _synctex_new_glue(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_medium_node_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_glue:(synctex_class_t)&synctex_class_glue;
-	}
-	return node;
-}
+DEFINE_synctex_new_NODE(glue)
 
 /*  boundary node creator */
+typedef synctex_node_small_t synctex_node_boundary_t;
 synctex_node_t _synctex_new_boundary(synctex_scanner_t scanner);
 void _synctex_display_boundary(synctex_node_t node);
 
@@ -675,17 +680,11 @@ static _synctex_class_t synctex_class_boundary = {
 	NULL,                       /*  No child */
 	&_synctex_implementation_1, /*  sibling */
 	&_synctex_implementation_2, /*  friend */
-	NULL,                       /*  No next box */
+	NULL,                       /*  No next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_3
 };
 
-synctex_node_t _synctex_new_boundary(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_small_node_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_boundary:(synctex_class_t)&synctex_class_boundary;
-	}
-	return node;
-}
+DEFINE_synctex_new_NODE(boundary)
 
 #   define SYNCTEX_NAME_IDX (SYNCTEX_TAG_IDX+1)
 #   define SYNCTEX_NAME(NODE) SYNCTEX_INFO(NODE)[SYNCTEX_NAME_IDX].PTR
@@ -693,6 +692,7 @@ synctex_node_t _synctex_new_boundary(synctex_scanner_t scanner) {
 /*  Input nodes only know about their sibling, which is another input node.
  *  The synctex information is the SYNCTEX_TAG and SYNCTEX_NAME*/
 typedef struct {
+    SYNCTEX_DECLARE_CHARINDEX;
 	synctex_class_t class;
 	synctex_info_t implementation[1+SYNCTEX_NAME_IDX+1]; /*  sibling,
 	                          *  SYNCTEX_TAG,SYNCTEX_NAME */
@@ -701,7 +701,7 @@ typedef struct {
 synctex_node_t _synctex_new_input(synctex_scanner_t scanner);
 void _synctex_free_input(synctex_node_t node);
 void _synctex_display_input(synctex_node_t node);
-void _synctex_log_input(synctex_node_t sheet);
+void _synctex_log_input(synctex_node_t node);
 
 static _synctex_class_t synctex_class_input = {
 	NULL,                       /*  No scanner yet */
@@ -714,16 +714,22 @@ static _synctex_class_t synctex_class_input = {
 	NULL,                       /*  No child */
 	&_synctex_implementation_0, /*  sibling */
 	NULL,                       /*  No friend */
-	NULL,                       /*  No next box */
+	NULL,                       /*  No next hbox */
 	(_synctex_info_getter_t)&_synctex_implementation_1
 };
 
+#   define SYNCTEX_INPUT_MARK "Input:"
+
 synctex_node_t _synctex_new_input(synctex_scanner_t scanner) {
-	synctex_node_t node = _synctex_malloc(sizeof(synctex_input_t));
-	if (node) {
-		node->class = scanner?scanner->class+synctex_node_type_input:(synctex_class_t)&synctex_class_input;
+	if (scanner) {
+		synctex_node_t node = _synctex_malloc(sizeof(synctex_input_t));
+		if (node) {
+            SYNCTEX_IMPLEMENT_CHARINDEX(node,strlen(SYNCTEX_INPUT_MARK));
+			node->class = scanner->class+synctex_node_type_input;
+		}
+		return node;
 	}
-	return node;
+	return NULL;
 }
 void _synctex_free_input(synctex_node_t node){
 	if (node) {
@@ -804,218 +810,267 @@ void synctex_node_log(synctex_node_t node) {
 	SYNCTEX_LOG(node);
 }
 
-#   define SYNCTEX_DISPLAY(NODE) SYNCTEX_MSG_SEND(NODE,display)
-
-void synctex_node_display(synctex_node_t node) {
-	SYNCTEX_DISPLAY(node);
-}
-
-void _synctex_display_input(synctex_node_t node) {
-	printf("....Input:%i:%s\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_NAME(node));
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+void _synctex_log_input(synctex_node_t node) {
+	if (node) {
+        printf("%s:%i,%s",synctex_node_isa(node),SYNCTEX_TAG(node),SYNCTEX_NAME(node));
+        printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
+    }
 }
 
-void _synctex_log_sheet(synctex_node_t sheet) {
-	if (sheet) {
-		printf("%s:%i\n",synctex_node_isa(sheet),SYNCTEX_PAGE(sheet));
-		printf("SELF:%p",(void *)sheet);
-		printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(sheet));
-		printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(sheet));
-		printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(sheet));
-		printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(sheet));
+void _synctex_log_sheet(synctex_node_t node) {
+	if (node) {
+		printf("%s:%i",synctex_node_isa(node),SYNCTEX_PAGE(node));
+        SYNCTEX_PRINT_CHARINDEX;
+		printf("SELF:%p",(void *)node);
+		printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
+		printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
+		printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
+		printf(" SYNCTEX_FRIEND:%p",(void *)SYNCTEX_FRIEND(node));
+        printf(" SYNCTEX_NEXT_hbox:%p\n",(void *)SYNCTEX_NEXT_hbox(node));
 	}
 }
 
 void _synctex_log_small_node(synctex_node_t node) {
-	printf("%s:%i,%i:%i,%i\n",
-		synctex_node_isa(node),
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node));
-	printf("SELF:%p",(void *)node);
-	printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
-	printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
-	printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
-	printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(node));
+	if (node) {
+        printf("%s:%i,%i:%i,%i",
+            synctex_node_isa(node),
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        printf("SELF:%p",(void *)node);
+        printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
+        printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
+        printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
+        printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(node));
+    }
 }
 
 void _synctex_log_medium_node(synctex_node_t node) {
-	printf("%s:%i,%i:%i,%i:%i\n",
-		synctex_node_isa(node),
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node),
-		SYNCTEX_WIDTH(node));
-	printf("SELF:%p",(void *)node);
-	printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
-	printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
-	printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
-	printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(node));
+	if (node) {
+        printf("%s:%i,%i:%i,%i:%i",
+            synctex_node_isa(node),
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node),
+            SYNCTEX_WIDTH(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        printf("SELF:%p",(void *)node);
+        printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
+        printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
+        printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
+        printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(node));
+    }
 }
 
 void _synctex_log_void_box(synctex_node_t node) {
-	printf("%s",synctex_node_isa(node));
-	printf(":%i",SYNCTEX_TAG(node));
-	printf(",%i",SYNCTEX_LINE(node));
-	printf(",%i",0);
-	printf(":%i",SYNCTEX_HORIZ(node));
-	printf(",%i",SYNCTEX_VERT(node));
-	printf(":%i",SYNCTEX_WIDTH(node));
-	printf(",%i",SYNCTEX_HEIGHT(node));
-	printf(",%i",SYNCTEX_DEPTH(node));
-	printf("\nSELF:%p",(void *)node);
-	printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
-	printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
-	printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
-	printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(node));
+	if (node) {
+        printf("%s",synctex_node_isa(node));
+        printf(":%i",SYNCTEX_TAG(node));
+        printf(",%i",SYNCTEX_LINE(node));
+        printf(",%i",0);
+        printf(":%i",SYNCTEX_HORIZ(node));
+        printf(",%i",SYNCTEX_VERT(node));
+        printf(":%i",SYNCTEX_WIDTH(node));
+        printf(",%i",SYNCTEX_HEIGHT(node));
+        printf(",%i",SYNCTEX_DEPTH(node));
+        SYNCTEX_PRINT_CHARINDEX;
+        printf("SELF:%p",(void *)node);
+        printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
+        printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
+        printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
+        printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(node));
+    }
+}
+
+void _synctex_log_vbox(synctex_node_t node) {
+	if (node) {
+        printf("%s",synctex_node_isa(node));
+        printf(":%i",SYNCTEX_TAG(node));
+        printf(",%i",SYNCTEX_LINE(node));
+        printf(",%i",0);
+        printf(":%i",SYNCTEX_HORIZ(node));
+        printf(",%i",SYNCTEX_VERT(node));
+        printf(":%i",SYNCTEX_WIDTH(node));
+        printf(",%i",SYNCTEX_HEIGHT(node));
+        printf(",%i",SYNCTEX_DEPTH(node));
+        SYNCTEX_PRINT_CHARINDEX;
+        printf("SELF:%p",(void *)node);
+        printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
+        printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
+        printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
+        printf(" SYNCTEX_FRIEND:%p",(void *)SYNCTEX_FRIEND(node));
+        printf(" SYNCTEX_NEXT_hbox:%p\n",(void *)SYNCTEX_NEXT_hbox(node));
+    }
 }
 
-void _synctex_log_box(synctex_node_t node) {
-	printf("%s",synctex_node_isa(node));
-	printf(":%i",SYNCTEX_TAG(node));
-	printf(",%i",SYNCTEX_LINE(node));
-	printf(",%i",0);
-	printf(":%i",SYNCTEX_HORIZ(node));
-	printf(",%i",SYNCTEX_VERT(node));
-	printf(":%i",SYNCTEX_WIDTH(node));
-	printf(",%i",SYNCTEX_HEIGHT(node));
-	printf(",%i",SYNCTEX_DEPTH(node));
-	printf("\nSELF:%p",(void *)node);
-	printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
-	printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
-	printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
-	printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(node));
+void _synctex_log_hbox(synctex_node_t node) {
+	if (node) {
+        printf("%s",synctex_node_isa(node));
+        printf(":%i",SYNCTEX_TAG(node));
+        printf(",%i~%i*%i",SYNCTEX_LINE(node),SYNCTEX_MEAN_LINE(node),SYNCTEX_NODE_WEIGHT(node));
+        printf(",%i",0);
+        printf(":%i",SYNCTEX_HORIZ(node));
+        printf(",%i",SYNCTEX_VERT(node));
+        printf(":%i",SYNCTEX_WIDTH(node));
+        printf(",%i",SYNCTEX_HEIGHT(node));
+        printf(",%i",SYNCTEX_DEPTH(node));
+        printf("/%i",SYNCTEX_HORIZ_V(node));
+        printf(",%i",SYNCTEX_VERT_V(node));
+        printf(":%i",SYNCTEX_WIDTH_V(node));
+        printf(",%i",SYNCTEX_HEIGHT_V(node));
+        printf(",%i",SYNCTEX_DEPTH_V(node));
+        SYNCTEX_PRINT_CHARINDEX;
+        printf("SELF:%p",(void *)node);
+        printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
+        printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
+        printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
+        printf(" SYNCTEX_FRIEND:%p",(void *)SYNCTEX_FRIEND(node));
+        printf(" SYNCTEX_NEXT_hbox:%p\n",(void *)SYNCTEX_NEXT_hbox(node));
+    }
 }
 
-void _synctex_log_horiz_box(synctex_node_t node) {
-	printf("%s",synctex_node_isa(node));
-	printf(":%i",SYNCTEX_TAG(node));
-	printf(",%i",SYNCTEX_LINE(node));
-	printf(",%i",0);
-	printf(":%i",SYNCTEX_HORIZ(node));
-	printf(",%i",SYNCTEX_VERT(node));
-	printf(":%i",SYNCTEX_WIDTH(node));
-	printf(",%i",SYNCTEX_HEIGHT(node));
-	printf(",%i",SYNCTEX_DEPTH(node));
-	printf("/%i",SYNCTEX_HORIZ_V(node));
-	printf(",%i",SYNCTEX_VERT_V(node));
-	printf(":%i",SYNCTEX_WIDTH_V(node));
-	printf(",%i",SYNCTEX_HEIGHT_V(node));
-	printf(",%i",SYNCTEX_DEPTH_V(node));
-	printf("\nSELF:%p",(void *)node);
-	printf(" SYNCTEX_PARENT:%p",(void *)SYNCTEX_PARENT(node));
-	printf(" SYNCTEX_CHILD:%p",(void *)SYNCTEX_CHILD(node));
-	printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
-	printf(" SYNCTEX_FRIEND:%p\n",(void *)SYNCTEX_FRIEND(node));
+#   define SYNCTEX_DISPLAY(NODE) SYNCTEX_MSG_SEND(NODE,display)
+
+void synctex_node_display(synctex_node_t node) {
+	SYNCTEX_DISPLAY(node);
 }
 
-void _synctex_log_input(synctex_node_t node) {
-	printf("%s",synctex_node_isa(node));
-	printf(":%i",SYNCTEX_TAG(node));
-	printf(",%s",SYNCTEX_NAME(node));
-	printf(" SYNCTEX_SIBLING:%p",(void *)SYNCTEX_SIBLING(node));
+void _synctex_display_input(synctex_node_t node) {
+    if (node) {
+        printf("....Input:%i:%s",
+            SYNCTEX_TAG(node),
+            SYNCTEX_NAME(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
-void _synctex_display_sheet(synctex_node_t sheet) {
-	if (sheet) {
-		printf("....{%i\n",SYNCTEX_PAGE(sheet));
-		SYNCTEX_DISPLAY(SYNCTEX_CHILD(sheet));
+void _synctex_display_sheet(synctex_node_t node) {
+	if (node) {
+		printf("....{%i",SYNCTEX_PAGE(node));
+        SYNCTEX_PRINT_CHARINDEX;
+		SYNCTEX_DISPLAY(SYNCTEX_CHILD(node));
 		printf("....}\n");
-		SYNCTEX_DISPLAY(SYNCTEX_SIBLING(sheet));
+		SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
 	}
 }
 
 void _synctex_display_vbox(synctex_node_t node) {
-	printf("....[%i,%i:%i,%i:%i,%i,%i\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node),
-		SYNCTEX_WIDTH(node),
-		SYNCTEX_HEIGHT(node),
-		SYNCTEX_DEPTH(node));
-	SYNCTEX_DISPLAY(SYNCTEX_CHILD(node));
-	printf("....]\n");
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    if (node) {
+        printf("....[%i,%i:%i,%i:%i,%i,%i",
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node),
+            SYNCTEX_WIDTH(node),
+            SYNCTEX_HEIGHT(node),
+            SYNCTEX_DEPTH(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_CHILD(node));
+        printf("....]\n");
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
 void _synctex_display_hbox(synctex_node_t node) {
-	printf("....(%i,%i:%i,%i:%i,%i,%i\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node),
-		SYNCTEX_WIDTH(node),
-		SYNCTEX_HEIGHT(node),
-		SYNCTEX_DEPTH(node));
-	SYNCTEX_DISPLAY(SYNCTEX_CHILD(node));
-	printf("....)\n");
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    if (node) {
+        printf("....(%i,%i~%i*%i:%i,%i:%i,%i,%i",
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_MEAN_LINE(node),
+            SYNCTEX_NODE_WEIGHT(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node),
+            SYNCTEX_WIDTH(node),
+            SYNCTEX_HEIGHT(node),
+            SYNCTEX_DEPTH(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_CHILD(node));
+        printf("....)\n");
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
 void _synctex_display_void_vbox(synctex_node_t node) {
-	printf("....v%i,%i;%i,%i:%i,%i,%i\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node),
-		SYNCTEX_WIDTH(node),
-		SYNCTEX_HEIGHT(node),
-		SYNCTEX_DEPTH(node));
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    if (node) {
+        printf("....v%i,%i;%i,%i:%i,%i,%i",
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node),
+            SYNCTEX_WIDTH(node),
+            SYNCTEX_HEIGHT(node),
+            SYNCTEX_DEPTH(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
 void _synctex_display_void_hbox(synctex_node_t node) {
-	printf("....h%i,%i:%i,%i:%i,%i,%i\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node),
-		SYNCTEX_WIDTH(node),
-		SYNCTEX_HEIGHT(node),
-		SYNCTEX_DEPTH(node));
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    if (node) {
+        printf("....h%i,%i:%i,%i:%i,%i,%i",
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node),
+            SYNCTEX_WIDTH(node),
+            SYNCTEX_HEIGHT(node),
+            SYNCTEX_DEPTH(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
 void _synctex_display_glue(synctex_node_t node) {
-	printf("....glue:%i,%i:%i,%i\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node));
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    if (node) {
+        printf("....glue:%i,%i:%i,%i",
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
 void _synctex_display_math(synctex_node_t node) {
-	printf("....math:%i,%i:%i,%i\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node));
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    if (node) {
+        printf("....math:%i,%i:%i,%i",
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
 void _synctex_display_kern(synctex_node_t node) {
-	printf("....kern:%i,%i:%i,%i:%i\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node),
-		SYNCTEX_WIDTH(node));
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    if (node) {
+        printf("....kern:%i,%i:%i,%i:%i",
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node),
+            SYNCTEX_WIDTH(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
 void _synctex_display_boundary(synctex_node_t node) {
-	printf("....boundary:%i,%i:%i,%i\n",
-		SYNCTEX_TAG(node),
-		SYNCTEX_LINE(node),
-		SYNCTEX_HORIZ(node),
-		SYNCTEX_VERT(node));
-	SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    if (node) {
+        printf("....boundary:%i,%i:%i,%i",
+            SYNCTEX_TAG(node),
+            SYNCTEX_LINE(node),
+            SYNCTEX_HORIZ(node),
+            SYNCTEX_VERT(node));
+            SYNCTEX_PRINT_CHARINDEX;
+        SYNCTEX_DISPLAY(SYNCTEX_SIBLING(node));
+    }
 }
 
 #	ifdef SYNCTEX_NOTHING
@@ -1058,10 +1113,6 @@ typedef int synctex_status_t;
 #       pragma mark -
 #       pragma mark Prototypes
 #   endif
-void _synctex_log_void_box(synctex_node_t node);
-void _synctex_log_box(synctex_node_t node);
-void _synctex_log_horiz_box(synctex_node_t node);
-void _synctex_log_input(synctex_node_t node);
 synctex_status_t _synctex_buffer_get_available_size(synctex_scanner_t scanner, size_t * size_ptr);
 synctex_status_t _synctex_next_line(synctex_scanner_t scanner);
 synctex_status_t _synctex_match_string(synctex_scanner_t scanner, const char * the_string);
@@ -1073,7 +1124,7 @@ synctex_status_t _synctex_scan_float_and_dimension(synctex_scanner_t scanner, fl
 synctex_status_t _synctex_scan_post_scriptum(synctex_scanner_t scanner);
 int _synctex_scan_postamble(synctex_scanner_t scanner);
 synctex_status_t _synctex_setup_visible_box(synctex_node_t box);
-synctex_status_t _synctex_horiz_box_setup_visible(synctex_node_t node,int h, int v);
+synctex_status_t _synctex_hbox_setup_visible(synctex_node_t node,int h, int v);
 synctex_status_t _synctex_scan_sheet(synctex_scanner_t scanner, synctex_node_t parent);
 synctex_status_t _synctex_scan_nested_sheet(synctex_scanner_t scanner);
 synctex_status_t _synctex_scan_content(synctex_scanner_t scanner);
@@ -1112,6 +1163,9 @@ synctex_status_t _synctex_buffer_get_available_size(synctex_scanner_t scanner, s
 		/*  Copy the remaining part of the buffer to the beginning,
 		 *  then read the next part of the file */
 		int already_read = 0;
+#   if defined(SYNCTEX_USE_CHARINDEX)
+        scanner->charindex_offset += SYNCTEX_CUR - SYNCTEX_START;
+#   endif
 		if (available) {
 			memmove(SYNCTEX_START, SYNCTEX_CUR, available);
 		}
@@ -1230,7 +1284,7 @@ return_OK:
 		SYNCTEX_CUR += remaining_len;
 		return SYNCTEX_STATUS_OK;
 	} else if (strncmp((char *)SYNCTEX_CUR,the_string,available)) {
-			/*  No need to goo further, this is not the expected string in the buffer. */
+			/*  No need to go further, this is not the expected string in the buffer. */
 			return SYNCTEX_STATUS_NOT_OK;
 	} else if (SYNCTEX_FILE) {
 		/*  The buffer was too small to contain remaining_len characters.
@@ -1471,7 +1525,7 @@ synctex_status_t _synctex_scan_input(synctex_scanner_t scanner) {
 	if (NULL == scanner) {
 		return SYNCTEX_STATUS_BAD_ARGUMENT;
 	}
-	status = _synctex_match_string(scanner,"Input:");
+	status = _synctex_match_string(scanner,SYNCTEX_INPUT_MARK);
 	if (status<SYNCTEX_STATUS_OK) {
 		return status;
 	}
@@ -1509,6 +1563,9 @@ synctex_status_t _synctex_scan_input(synctex_scanner_t scanner) {
 	/*  Prepend this input node to the input linked list of the scanner */
 	SYNCTEX_SET_SIBLING(input,scanner->input);
 	scanner->input = input;
+#   if SYNCTEX_VERBOSE
+        synctex_node_log(input);
+#   endif
 	return _synctex_next_line(scanner);/*  read the line termination character, if any */
 	/*  Now, set up the path */
 }
@@ -1836,7 +1893,7 @@ synctex_status_t _synctex_setup_visible_box(synctex_node_t box) {
  *  Some box have 0 width but do contain text material.
  *  With this method, one can enlarge the box to contain the given point (h,v).
  */
-synctex_status_t _synctex_horiz_box_setup_visible(synctex_node_t node,int h, int v) {
+synctex_status_t _synctex_hbox_setup_visible(synctex_node_t node,int h, int v) {
 #	ifdef __DARWIN_UNIX03
 #       pragma unused(v)
 #   endif
@@ -1945,7 +2002,6 @@ prepare_loop:
 	if (SYNCTEX_CUR<SYNCTEX_END) {
 		if (*SYNCTEX_CUR == SYNCTEX_CHAR_BEGIN_VBOX) {
 scan_vbox:
-			++SYNCTEX_CUR;
 			if ((child = _synctex_new_vbox(scanner)) && (info = SYNCTEX_INFO(child))) {
 #               define SYNCTEX_DECODE_FAILED(WHAT) \
 					(_synctex_decode_int(scanner,&(info[WHAT].INT))<SYNCTEX_STATUS_OK)
@@ -1963,14 +2019,13 @@ scan_vbox:
 				SYNCTEX_SET_CHILD(parent,child);
 				parent = child;
 				child = NULL;
-				goto child_loop;/*  next created node will be a child */
+ 				goto child_loop;/*  next created node will be a child */
 			} else {
 				_synctex_error("Can't create vbox record.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_BEGIN_HBOX) {
 scan_hbox:
-			++SYNCTEX_CUR;
 			if ((child = _synctex_new_hbox(scanner)) && (info = SYNCTEX_INFO(child))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
 						|| SYNCTEX_DECODE_FAILED(SYNCTEX_LINE_IDX)
@@ -1984,8 +2039,8 @@ scan_hbox:
 					_synctex_error("Bad hbox record.");
 					SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 				}
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child)+SYNCTEX_ABS_WIDTH(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child)+SYNCTEX_ABS_WIDTH(child),SYNCTEX_VERT(child));
 				SYNCTEX_SET_CHILD(parent,child);
 				parent = child;
 				child = NULL;
@@ -2002,6 +2057,9 @@ scan_teehs:
 				_synctex_error("Unexpected end of sheet.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
+#           if SYNCTEX_VERBOSE
+                synctex_node_log(parent);
+#           endif
 			SYNCTEX_RETURN(SYNCTEX_STATUS_OK);
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_BEGIN_SHEET) {
 			/*  Addendum to version 1.10 to manage nested sheets  */
@@ -2034,12 +2092,11 @@ scan_anchor:
 		 if (status<SYNCTEX_STATUS_OK && available>0){
 			_synctex_error("Uncomplete sheet(0)");
 			SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
-		} else {
-			goto prepare_loop;
 		}
+        goto prepare_loop;
 	}
 	_synctex_bail();
-/*  The child loop means that we go do one level, when we just created a box node,
+/*  The child loop means that we go down one level, when we just created a box node,
  *  the next node created is a child of this box. */
 child_loop:
 	if (SYNCTEX_CUR<SYNCTEX_END) {
@@ -2066,6 +2123,9 @@ scan_xobv:
 				_synctex_error("Uncomplete sheet.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
+#           if SYNCTEX_VERBOSE
+                synctex_node_log(child);
+#           endif
 			goto sibling_loop;
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_BEGIN_HBOX) {
 			goto scan_hbox;
@@ -2073,26 +2133,53 @@ scan_xobv:
 scan_xobh:
 			++SYNCTEX_CUR;
 			if ((parent) && parent->class->type == synctex_node_type_hbox) {
+            /*  Update the mean line number */
+                synctex_node_t node = SYNCTEX_CHILD(parent);
+                if (node) {
+                    unsigned int node_weight = 0;
+                    unsigned int cumulated_line_numbers = 0;
+                    do {
+                        if (synctex_node_type(node)==synctex_node_type_hbox) {
+                            if (SYNCTEX_NODE_WEIGHT(node)) {
+                                node_weight += SYNCTEX_NODE_WEIGHT(node);
+                                cumulated_line_numbers += SYNCTEX_MEAN_LINE(node)*SYNCTEX_NODE_WEIGHT(node);
+                            } else {
+                                ++node_weight;
+                                cumulated_line_numbers += SYNCTEX_MEAN_LINE(node);
+                            }
+                        } else {
+                            ++node_weight;
+                            cumulated_line_numbers += SYNCTEX_LINE(node);
+                        }
+                    } while ((node = SYNCTEX_SIBLING(node)));
+                    SYNCTEX_MEAN_LINE(parent)=(cumulated_line_numbers + node_weight/2)/node_weight;
+                    SYNCTEX_NODE_WEIGHT(parent)=node_weight;
+                } else {
+                    SYNCTEX_MEAN_LINE(parent)=SYNCTEX_LINE(parent);
+                    SYNCTEX_NODE_WEIGHT(parent)=1;
+                }
 				if (NULL == child) {
 					/*  Only boxes with no children are friends,
-					 *  boxes with children are indirectly friends through one of their descendants. */
+					 *  boxes with children are indirectly friends through one of their contained nodes. */
 					SYNCTEX_UPDATE_BOX_FRIEND(parent);
 				}
 				/*  setting the next horizontal box at the end ensures that a child is recorded before any of its ancestors. */
-				SYNCTEX_SET_NEXT_HORIZ_BOX(box,parent);
+				SYNCTEX_SET_NEXT_hbox(box,parent);
 				box = parent;
 				child = parent;
 				parent = SYNCTEX_PARENT(child);
 			} else {
-				_synctex_error("Unexpected enf of hbox, ignored.");
+				_synctex_error("Unexpected end of hbox, ignored.");
 			}
 			if (_synctex_next_line(scanner)<SYNCTEX_STATUS_OK) {
 				_synctex_error("Uncomplete sheet.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
+#           if SYNCTEX_VERBOSE
+                synctex_node_log(child);
+#           endif
 			goto sibling_loop;
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_VOID_VBOX) {
-			++SYNCTEX_CUR;
 			if (NULL != (child = _synctex_new_void_vbox(scanner))
 					&& NULL != (info = SYNCTEX_INFO(child))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2112,13 +2199,15 @@ scan_xobh:
 				SYNCTEX_SET_FRIEND(NODE,(scanner->lists_of_friends)[friend_index]);\
 				(scanner->lists_of_friends)[friend_index] = NODE;
 				SYNCTEX_UPDATE_FRIEND(child);
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create vbox record.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_VOID_HBOX) {
-			++SYNCTEX_CUR;
 			if (NULL != (child = _synctex_new_void_hbox(scanner))
 					&& NULL != (info = SYNCTEX_INFO(child))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2134,15 +2223,17 @@ scan_xobh:
 				}
 				SYNCTEX_SET_CHILD(parent,child);
 				SYNCTEX_UPDATE_FRIEND(child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child)+SYNCTEX_ABS_WIDTH(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child)+SYNCTEX_ABS_WIDTH(child),SYNCTEX_VERT(child));
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create void hbox record.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_KERN) {
-			++SYNCTEX_CUR;
 			if (NULL != (child = _synctex_new_kern(scanner))
 					&& NULL != (info = SYNCTEX_INFO(child))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2156,15 +2247,17 @@ scan_xobh:
 				}
 				SYNCTEX_SET_CHILD(parent,child);
 				SYNCTEX_UPDATE_FRIEND(child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child)-SYNCTEX_WIDTH(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child)-SYNCTEX_WIDTH(child),SYNCTEX_VERT(child));
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create kern record.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_GLUE) {
-			++SYNCTEX_CUR;
 			if (NULL != (child = _synctex_new_glue(scanner))
 					&& NULL != (info = SYNCTEX_INFO(child))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2176,15 +2269,17 @@ scan_xobh:
 					SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 				}
 				SYNCTEX_SET_CHILD(parent,child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
 				SYNCTEX_UPDATE_FRIEND(child);
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create glue record.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_MATH) {
-			++SYNCTEX_CUR;
 			if (NULL != (child = _synctex_new_math(scanner))
 					&& NULL != (info = SYNCTEX_INFO(child))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2196,15 +2291,17 @@ scan_xobh:
 					SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 				}
 				SYNCTEX_SET_CHILD(parent,child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
 				SYNCTEX_UPDATE_FRIEND(child);
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create math record.");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_BOUNDARY) {
-			++SYNCTEX_CUR;
 			if (NULL != (child = _synctex_new_boundary(scanner))
 					&& NULL != (info = SYNCTEX_INFO(child))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2216,8 +2313,11 @@ scan_xobh:
 					SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 				}
 				SYNCTEX_SET_CHILD(parent,child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
 				SYNCTEX_UPDATE_FRIEND(child);
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create math record.");
@@ -2260,7 +2360,6 @@ scan_xobh:
 sibling_loop:
 	if (SYNCTEX_CUR<SYNCTEX_END) {
 		if (*SYNCTEX_CUR == SYNCTEX_CHAR_BEGIN_VBOX) {
-			++SYNCTEX_CUR;
 			if (NULL != (sibling = _synctex_new_vbox(scanner))
 					&& NULL != (info = SYNCTEX_INFO(sibling))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2285,7 +2384,6 @@ sibling_loop:
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_END_VBOX) {
 			goto scan_xobv;
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_BEGIN_HBOX) {
-			++SYNCTEX_CUR;
 			if (NULL != (sibling = _synctex_new_hbox(scanner)) &&
 					NULL != (info = SYNCTEX_INFO(sibling))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2302,8 +2400,11 @@ sibling_loop:
 				}
 				SYNCTEX_SET_SIBLING(child,sibling);
 				child = sibling;
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child)+SYNCTEX_ABS_WIDTH(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child)+SYNCTEX_ABS_WIDTH(child),SYNCTEX_VERT(child));
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				parent = child;
 				child = NULL;
 				goto child_loop;
@@ -2314,7 +2415,6 @@ sibling_loop:
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_END_HBOX) {
 			goto scan_xobh;
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_VOID_VBOX) {
-			++SYNCTEX_CUR;
 			if (NULL != (sibling = _synctex_new_void_vbox(scanner)) &&
 					NULL != (info = SYNCTEX_INFO(sibling))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2330,6 +2430,9 @@ sibling_loop:
 				}
 				SYNCTEX_SET_SIBLING(child,sibling);
 				child = sibling;
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				SYNCTEX_UPDATE_FRIEND(child);
 				goto sibling_loop;
 			} else {
@@ -2337,7 +2440,6 @@ sibling_loop:
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_VOID_HBOX) {
-			++SYNCTEX_CUR;
 			if (NULL != (sibling = _synctex_new_void_hbox(scanner)) &&
 					NULL != (info = SYNCTEX_INFO(sibling))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2353,16 +2455,18 @@ sibling_loop:
 				}
 				SYNCTEX_SET_SIBLING(child,sibling);
 				child = sibling;
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				SYNCTEX_UPDATE_FRIEND(child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child)+SYNCTEX_ABS_WIDTH(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child)+SYNCTEX_ABS_WIDTH(child),SYNCTEX_VERT(child));
 				goto sibling_loop;
 			} else {
 				_synctex_error("can't create void hbox record (2).");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_KERN) {
-			++SYNCTEX_CUR;
 			if (NULL != (sibling = _synctex_new_kern(scanner))
 					&& NULL != (info = SYNCTEX_INFO(sibling))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2376,16 +2480,18 @@ sibling_loop:
 				}
 				SYNCTEX_SET_SIBLING(child,sibling);
 				child = sibling;
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				SYNCTEX_UPDATE_FRIEND(child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child)-SYNCTEX_WIDTH(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child)-SYNCTEX_WIDTH(child),SYNCTEX_VERT(child));
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create kern record (2).");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_GLUE) {
-			++SYNCTEX_CUR;
 			if (NULL != (sibling = _synctex_new_glue(scanner))
 					&& NULL != (info = SYNCTEX_INFO(sibling))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2398,15 +2504,17 @@ sibling_loop:
 				}
 				SYNCTEX_SET_SIBLING(child,sibling);
 				child = sibling;
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				SYNCTEX_UPDATE_FRIEND(child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create glue record (2).");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_MATH) {
-			++SYNCTEX_CUR;
 			if (NULL != (sibling = _synctex_new_math(scanner))
 					&& NULL != (info = SYNCTEX_INFO(sibling))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2419,15 +2527,17 @@ sibling_loop:
 				}
 				SYNCTEX_SET_SIBLING(child,sibling);
 				child = sibling;
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				SYNCTEX_UPDATE_FRIEND(child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create math record (2).");
 				SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR);
 			}
 		} else if (*SYNCTEX_CUR == SYNCTEX_CHAR_BOUNDARY) {
-			++SYNCTEX_CUR;
 			if (NULL != (sibling = _synctex_new_boundary(scanner))
 					&& NULL != (info = SYNCTEX_INFO(sibling))) {
 				if (SYNCTEX_DECODE_FAILED(SYNCTEX_TAG_IDX)
@@ -2440,8 +2550,11 @@ sibling_loop:
 				}
 				SYNCTEX_SET_SIBLING(child,sibling);
 				child = sibling;
+#               if SYNCTEX_VERBOSE
+                    synctex_node_log(child);
+#               endif
 				SYNCTEX_UPDATE_FRIEND(child);
-				_synctex_horiz_box_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
+				_synctex_hbox_setup_visible(parent,SYNCTEX_HORIZ(child),SYNCTEX_VERT(child));
 				goto sibling_loop;
 			} else {
 				_synctex_error("Can't create boundary record (2).");
@@ -2477,6 +2590,17 @@ sibling_loop:
 #   undef SYNCTEX_DECODE_FAILED
 }
 
+#   define SYNCTEX_APPEND_SHEET(SCANNER,SHEET) if (SCANNER->sheet) {\
+        synctex_node_t last_sheet = SCANNER->sheet;\
+        synctex_node_t next_sheet = NULL;\
+        while ((next_sheet = SYNCTEX_SIBLING(last_sheet))) {\
+            last_sheet = next_sheet;\
+        }\
+		SYNCTEX_SET_SIBLING(last_sheet,SHEET);\
+    } else {\
+        SCANNER->sheet = SHEET;\
+    }
+
 /*  Used when parsing the synctex file
  */
 synctex_status_t _synctex_scan_content(synctex_scanner_t scanner) {
@@ -2524,7 +2648,6 @@ next_sheet:
 		}
 		return SYNCTEX_STATUS_OK;
 	}
-	++SYNCTEX_CUR;
 	/*  Create a new sheet node */
 	sheet = _synctex_new_sheet(scanner);
 	status = _synctex_decode_int(scanner,&(SYNCTEX_PAGE(sheet)));
@@ -2544,8 +2667,7 @@ bail:
 		_synctex_error("Bad sheet content.");
 		goto bail;
 	}
-	SYNCTEX_SET_SIBLING(sheet,scanner->sheet);
-	scanner->sheet = sheet;
+	SYNCTEX_APPEND_SHEET(scanner,sheet);
 	sheet = NULL;
 	/*  Now read the list of Inputs between 2 sheets. */
 	do {
@@ -2574,12 +2696,12 @@ synctex_scanner_t synctex_scanner_new_with_output_file(const char * output, cons
 	}
 	/*  We ensure that SYNCTEX_BUFFER_SIZE < UINT_MAX, I don't know if it makes sense... */
 	if (SYNCTEX_BUFFER_SIZE >= UINT_MAX) {
-		_synctex_error("SyncTeX BUG: Internal inconsistency, bad SYNCTEX_BUFFER_SIZE (1)");
+		_synctex_error("Internal inconsistency, bad SYNCTEX_BUFFER_SIZE (1)");
 		return NULL;
 	}
 	/*  for integers: */
 	if (SYNCTEX_BUFFER_SIZE < SYNCTEX_BUFFER_MIN_SIZE) {
-		_synctex_error("SyncTeX BUG: Internal inconsistency, bad SYNCTEX_BUFFER_SIZE (2)");
+		_synctex_error("Internal inconsistency, bad SYNCTEX_BUFFER_SIZE (2)");
 		return NULL;
 	}
 	/*  now open the synctex file */
@@ -2590,7 +2712,7 @@ synctex_scanner_t synctex_scanner_new_with_output_file(const char * output, cons
 	}
 	scanner = (synctex_scanner_t)_synctex_malloc(sizeof(_synctex_scanner_t));
 	if (NULL == scanner) {
-		_synctex_error("SyncTeX: malloc problem");
+		_synctex_error("malloc problem");
 		free(synctex);
 		gzclose(file);
 		return NULL;
@@ -2668,7 +2790,7 @@ return_on_error:
 			/*  Could not open this file */
 			if (errno != ENOENT) {
 				/*  The file does exist, this is a lower level error, I can't do anything. */
-				_synctex_error("SyncTeX: could not open %s, error %i\n",synctex_name,errno);
+				_synctex_error("could not open %s, error %i\n",synctex_name,errno);
 				goto return_on_error;
 			}
 			/*  Apparently, there is no uncompressed synctex file. Try the compressed version */
@@ -2687,7 +2809,7 @@ return_on_error:
 				/*  Could not open this file */
 				if (errno != ENOENT) {
 					/*  The file does exist, this is a lower level error, I can't do anything. */
-					_synctex_error("SyncTeX: could not open %s, error %i\n",synctex_name,errno);
+					_synctex_error("Could not open %s, error %i\n",synctex_name,errno);
 				}
 				goto return_on_error;
 			}
@@ -2697,14 +2819,14 @@ return_on_error:
 		if (quoteless_synctex_name) {
 			gzclose(the_file);
 			if (rename(synctex_name,quoteless_synctex_name)) {
-				_synctex_error("SyncTeX: could not rename %s to %s, error %i\n",synctex_name,quoteless_synctex_name,errno);
+				_synctex_error("Could not rename %s to %s, error %i\n",synctex_name,quoteless_synctex_name,errno);
 				/*	We could not rename, reopen the file with the quoted name. */
 				if (NULL == (the_file = gzopen(synctex_name,mode))) {
 					/*  No luck, could not re open this file, something has happened meanwhile */
 					if (errno != ENOENT) {
 						/*  The file does not exist any more, it has certainly be removed somehow
                          *  this is a lower level error, I can't do anything. */
-						_synctex_error("SyncTeX: could not open again %s, error %i\n",synctex_name,errno);
+						_synctex_error("Could not open again %s, error %i\n",synctex_name,errno);
 					}
 					goto return_on_error;
 				}
@@ -2714,7 +2836,7 @@ return_on_error:
 					/*  Could not open this file */
 					if (errno != ENOENT) {
 						/*  The file does exist, this is a lower level error, I can't do anything. */
-						_synctex_error("SyncTeX: could not open renamed %s, error %i\n",quoteless_synctex_name,errno);
+						_synctex_error("Could not open renamed %s, error %i\n",quoteless_synctex_name,errno);
 					}
 					goto return_on_error;
 				}
@@ -2814,29 +2936,22 @@ synctex_scanner_t synctex_scanner_parse(synctex_scanner_t scanner) {
 	/*  initialize the offset with a fake unprobable value,
 	 *  If there is a post scriptum section, this value will be overriden by the real life value */
 	scanner->x_offset = scanner->y_offset = 6.027e23f;
-	scanner->class[synctex_node_type_sheet] = synctex_class_sheet;
-	scanner->class[synctex_node_type_input] = synctex_class_input;
-	(scanner->class[synctex_node_type_input]).scanner = scanner;
-	(scanner->class[synctex_node_type_sheet]).scanner = scanner;
-	scanner->class[synctex_node_type_vbox] = synctex_class_vbox;
-	(scanner->class[synctex_node_type_vbox]).scanner = scanner;
-	scanner->class[synctex_node_type_void_vbox] = synctex_class_void_vbox;
-	(scanner->class[synctex_node_type_void_vbox]).scanner = scanner;
-	scanner->class[synctex_node_type_hbox] = synctex_class_hbox;
-	(scanner->class[synctex_node_type_hbox]).scanner = scanner;
-	scanner->class[synctex_node_type_void_hbox] = synctex_class_void_hbox;
-	(scanner->class[synctex_node_type_void_hbox]).scanner = scanner;
-	scanner->class[synctex_node_type_kern] = synctex_class_kern;
-	(scanner->class[synctex_node_type_kern]).scanner = scanner;
-	scanner->class[synctex_node_type_glue] = synctex_class_glue;
-	(scanner->class[synctex_node_type_glue]).scanner = scanner;
-	scanner->class[synctex_node_type_math] = synctex_class_math;
-	(scanner->class[synctex_node_type_math]).scanner = scanner;
-	scanner->class[synctex_node_type_boundary] = synctex_class_boundary;
-	(scanner->class[synctex_node_type_boundary]).scanner = scanner;
+#   define DEFINE_synctex_scanner_class(NAME)\
+	scanner->class[synctex_node_type_##NAME] = synctex_class_##NAME;\
+	(scanner->class[synctex_node_type_##NAME]).scanner = scanner
+    DEFINE_synctex_scanner_class(sheet);
+    DEFINE_synctex_scanner_class(input);
+    DEFINE_synctex_scanner_class(hbox);
+    DEFINE_synctex_scanner_class(void_hbox);
+    DEFINE_synctex_scanner_class(vbox);
+    DEFINE_synctex_scanner_class(void_vbox);
+    DEFINE_synctex_scanner_class(kern);
+    DEFINE_synctex_scanner_class(glue);
+    DEFINE_synctex_scanner_class(math);
+    DEFINE_synctex_scanner_class(boundary);
 	SYNCTEX_START = (char *)malloc(SYNCTEX_BUFFER_SIZE+1); /*  one more character for null termination */
 	if (NULL == SYNCTEX_START) {
-		_synctex_error("SyncTeX: malloc error");
+		_synctex_error("malloc error");
 		synctex_scanner_free(scanner);
 		return NULL;
 	}
@@ -2846,6 +2961,9 @@ synctex_scanner_t synctex_scanner_parse(synctex_scanner_t scanner) {
 	 *  At least, we are sure that SYNCTEX_CUR points to a string covering a valid part of the memory. */
 	*SYNCTEX_END = '\0';
 	SYNCTEX_CUR = SYNCTEX_END;
+#   if defined(SYNCTEX_USE_CHARINDEX)
+    scanner->charindex_offset = -SYNCTEX_BUFFER_SIZE;
+#   endif
 	status = _synctex_scan_preamble(scanner);
 	if (status<SYNCTEX_STATUS_OK) {
 		_synctex_error("SyncTeX Error: Bad preamble\n");
@@ -2971,6 +3089,23 @@ int _synctex_scanner_get_tag(synctex_scanner_t scanner,const char * name) {
 			return SYNCTEX_TAG(input);
 		}
 	} while((input = SYNCTEX_SIBLING(input)) != NULL);
+    //  2011 version
+    name = _synctex_base_name(name);
+	input = scanner->input;
+	do {
+		if (_synctex_is_equivalent_file_name(name,_synctex_base_name(SYNCTEX_NAME(input)))) {
+            synctex_node_t other_input = input;
+            while((other_input = SYNCTEX_SIBLING(other_input)) != NULL) {
+                if (_synctex_is_equivalent_file_name(name,_synctex_base_name(SYNCTEX_NAME(other_input)))
+                    && (strlen(SYNCTEX_NAME(input))!=strlen(SYNCTEX_NAME(other_input))
+                        || strncmp(SYNCTEX_NAME(other_input),SYNCTEX_NAME(input),strlen(SYNCTEX_NAME(input))))) {
+                    // There is a second possible candidate
+                    return 0;
+                }
+            }
+			return SYNCTEX_TAG(input);
+		}
+	} while((input = SYNCTEX_SIBLING(input)) != NULL);
 	return 0;
 }
 
@@ -3252,12 +3387,21 @@ int synctex_node_page(synctex_node_t node){
 	}
 	return -1;
 }
+synctex_charindex_t synctex_node_charindex(synctex_node_t node) {
+	return node?SYNCTEX_CHARINDEX(node):0;
+}
 int synctex_node_tag(synctex_node_t node) {
 	return node?SYNCTEX_TAG(node):-1;
 }
 int synctex_node_line(synctex_node_t node) {
 	return node?SYNCTEX_LINE(node):-1;
 }
+int synctex_node_mean_line(synctex_node_t node) {
+	return node?(node->class->type==synctex_node_type_hbox?SYNCTEX_MEAN_LINE(node):SYNCTEX_LINE(node)):-1;
+}
+int synctex_node_child_count(synctex_node_t node) {
+	return node?(node->class->type==synctex_node_type_hbox?SYNCTEX_NODE_WEIGHT(node):0):-1;
+}
 int synctex_node_column(synctex_node_t node) {
 #	ifdef __DARWIN_UNIX03
 #       pragma unused(node)
@@ -3269,12 +3413,12 @@ int synctex_node_column(synctex_node_t node) {
 #       pragma mark Sheet
 #   endif
 
-synctex_node_t synctex_sheet_content(synctex_scanner_t scanner,int page) {
+synctex_node_t synctex_sheet(synctex_scanner_t scanner,int page) {
 	if (scanner) {
 		synctex_node_t sheet = scanner->sheet;
 		while(sheet) {
 			if (page == SYNCTEX_PAGE(sheet)) {
-				return SYNCTEX_CHILD(sheet);
+				return sheet;
 			}
 			sheet = SYNCTEX_SIBLING(sheet);
 		}
@@ -3282,6 +3426,13 @@ synctex_node_t synctex_sheet_content(synctex_scanner_t scanner,int page) {
 	return NULL;
 }
 
+synctex_node_t synctex_sheet_content(synctex_scanner_t scanner,int page) {
+	if (scanner) {
+		return SYNCTEX_CHILD(synctex_sheet(scanner,page));
+	}
+	return NULL;
+}
+
 #	ifdef SYNCTEX_NOTHING
 #       pragma mark -
 #       pragma mark Query
@@ -3321,7 +3472,7 @@ int synctex_display_query(synctex_scanner_t scanner,const char * name,int line,i
 					*(synctex_node_t *)SYNCTEX_CUR = node;
 					SYNCTEX_CUR += sizeof(synctex_node_t);
 				}
-			} while((node = SYNCTEX_FRIEND(node)));
+			} while ((node = SYNCTEX_FRIEND(node)));
 			if (SYNCTEX_START == NULL) {
 				/*  We did not find any matching boundary, retry with glue or kern */
 				node = (scanner->lists_of_friends)[friend_index];/*  no need to test it again, already done */
@@ -3339,7 +3490,7 @@ int synctex_display_query(synctex_scanner_t scanner,const char * name,int line,i
 						*(synctex_node_t *)SYNCTEX_CUR = node;
 						SYNCTEX_CUR += sizeof(synctex_node_t);
 					}
-				} while((node = SYNCTEX_FRIEND(node)));
+				} while ((node = SYNCTEX_FRIEND(node)));
 				if (SYNCTEX_START == NULL) {
 					/*  We did not find any matching glue or kern, retry with boxes */
 					node = (scanner->lists_of_friends)[friend_index];/*  no need to test it again, already done */
@@ -3360,29 +3511,58 @@ int synctex_display_query(synctex_scanner_t scanner,const char * name,int line,i
 				}
 			}
 			SYNCTEX_END = SYNCTEX_CUR;
-			/*  Now reverse the order to have nodes in display order, and keep just a few nodes */
-			if ((SYNCTEX_START) && (SYNCTEX_END))
-			{
+			/*  Now reverse the order to have nodes in display order, and then keep just a few nodes.
+             *  Order first the best node. */
+			if ((SYNCTEX_START) && (SYNCTEX_END)) {
+                unsigned int best_match = -1;
+                unsigned int next_match = -1;
+                unsigned int best_weight = 0;
+                synctex_node_t * best_ref   = NULL;
 				synctex_node_t * start_ref = (synctex_node_t *)SYNCTEX_START;
 				synctex_node_t * end_ref   = (synctex_node_t *)SYNCTEX_END;
-				end_ref -= 1;
-				while(start_ref < end_ref) {
+				--end_ref;
+				while (start_ref < end_ref) {
 					node = *start_ref;
 					*start_ref = *end_ref;
 					*end_ref = node;
-					start_ref += 1;
-					end_ref -= 1;
+					++start_ref;
+					--end_ref;
+				}
+                /*  Now reorder the nodes to put first the one which fits best.
+                 *  The idea is to walk along the list of nodes and pick up the first one
+                 *  which line info is exactly the mean line of its parent, or at least very close.
+                 *  Then we choose among all such node the one with the maximum number of child nodes.
+                 *  Then we switch with the first node.
+                 */
+                best_ref = start_ref = (synctex_node_t *)SYNCTEX_START;
+                node = *start_ref;
+                best_match = abs(SYNCTEX_LINE(node)-SYNCTEX_MEAN_LINE(SYNCTEX_PARENT(node)));
+                end_ref = (synctex_node_t *)SYNCTEX_END;
+				while (++start_ref<end_ref) {
+                    synctex_node_t parent = NULL;
+					node = *start_ref;
+                    parent = SYNCTEX_PARENT(node);
+                    next_match = abs(SYNCTEX_LINE(node)-SYNCTEX_MEAN_LINE(parent));
+                    if (next_match < best_match
+                            || (next_match == best_match && SYNCTEX_NODE_WEIGHT(parent)>best_weight)) {
+                        best_match = next_match;
+                        best_ref = start_ref;
+                        best_weight = SYNCTEX_NODE_WEIGHT(parent);
+                    }
 				}
+                node = *best_ref;
+                *best_ref = *(synctex_node_t *)SYNCTEX_START;
+                *(synctex_node_t *)SYNCTEX_START = node;
 				/*  Basically, we keep the first node for each parent.
-				 *  More precisely, we keep only nodes that are not descendants of
+				 *  More precisely, we keep only nodes that are not children of
 				 *  their predecessor's parent. */
 				start_ref = (synctex_node_t *)SYNCTEX_START;
 				end_ref   = (synctex_node_t *)SYNCTEX_START;
-		next_end:
+next_end:
 				end_ref += 1; /*  we allways have start_ref<= end_ref*/
 				if (end_ref < (synctex_node_t *)SYNCTEX_END) {
 					node = *end_ref;
-					while((node = SYNCTEX_PARENT(node))) {
+					while ((node = SYNCTEX_PARENT(node))) {
 						if (SYNCTEX_PARENT(*start_ref) == node) {
 							goto next_end;
 						}
@@ -3505,18 +3685,18 @@ int synctex_edit_query(synctex_scanner_t scanner,int page,float h,float v) {
 	 *  Then we try with the visible box dimensions.
 	 *  We try to find a non void box containing the hit point.
 	 *  We browse all the horizontal boxes until we find one containing the hit point. */
-	if ((node = SYNCTEX_NEXT_HORIZ_BOX(sheet))) {
+	if ((node = SYNCTEX_NEXT_hbox(sheet))) {
 		do {
 			if (_synctex_point_in_box(hitPoint,node,synctex_YES)) {
 				/*  Maybe the hitPoint belongs to a contained vertical box. */
 end:
 				/*  This trick is for catching overlapping boxes */
-				if ((other_node = SYNCTEX_NEXT_HORIZ_BOX(node))) {
+				if ((other_node = SYNCTEX_NEXT_hbox(node))) {
 					do {
 						if (_synctex_point_in_box(hitPoint,other_node,synctex_YES)) {
 							node = _synctex_smallest_container(other_node,node); 
 						}
-					} while((other_node = SYNCTEX_NEXT_HORIZ_BOX(other_node)));
+					} while((other_node = SYNCTEX_NEXT_hbox(other_node)));
 				}
                 /*  node is the smallest horizontal box that contains hitPoint. */
 				if ((bestContainer = _synctex_eq_deepest_container(hitPoint,node,synctex_YES))) {
@@ -3560,7 +3740,7 @@ end:
 				}
 				return SYNCTEX_STATUS_ERROR;
 			}
-		} while ((node = SYNCTEX_NEXT_HORIZ_BOX(node)));
+		} while ((node = SYNCTEX_NEXT_hbox(node)));
 		/*  All the horizontal boxes have been tested,
 		 *  None of them contains the hit point.
 		 */
@@ -3762,8 +3942,8 @@ SYNCTEX_INLINE static synctex_node_t _synctex_smallest_container(synctex_node_t
 	}
 	if (height>other_height) {
 		return other_node;
-	}
-	return node;
+    }
+    return node;
 }
 
 synctex_bool_t _synctex_point_in_box(synctex_point_t hitPoint, synctex_node_t node, synctex_bool_t visible) {
diff --git a/src/synctex_parser.h b/src/synctex_parser.h
index 4aca415..3151707 100644
--- a/src/synctex_parser.h
+++ b/src/synctex_parser.h
@@ -5,7 +5,7 @@ This file is part of the SyncTeX package.
 
 Latest Revision: Tue Jun 14 08:23:30 UTC 2011
 
-Version: 1.16
+Version: 1.17
 
 See synctex_parser_readme.txt for more details
 
@@ -236,6 +236,7 @@ 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 */
@@ -264,6 +265,11 @@ const char * synctex_node_isa(synctex_node_t 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.
@@ -274,6 +280,14 @@ 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.
  */
diff --git a/src/synctex_parser_utils.c b/src/synctex_parser_utils.c
index 569f7e9..0000f7e 100644
--- a/src/synctex_parser_utils.c
+++ b/src/synctex_parser_utils.c
@@ -5,7 +5,7 @@ This file is part of the SyncTeX package.
 
 Latest Revision: Tue Jun 14 08:23:30 UTC 2011
 
-Version: 1.16
+Version: 1.17
 
 See synctex_parser_readme.txt for more details
 
@@ -141,36 +141,57 @@ void _synctex_strip_last_path_extension(char * string) {
 	}
 }
 
-const char * synctex_ignore_leading_dot_slash(const char * name)
+synctex_bool_t synctex_ignore_leading_dot_slash_in_path(const char ** name_ref)
 {
-    while(SYNCTEX_IS_DOT(*name) && SYNCTEX_IS_PATH_SEPARATOR(name[1])) {
-        name += 2;
-        while (SYNCTEX_IS_PATH_SEPARATOR(*name)) {
-            ++name;
-        }
+    if (SYNCTEX_IS_DOT((*name_ref)[0]) && SYNCTEX_IS_PATH_SEPARATOR((*name_ref)[1])) {
+        do {
+            (*name_ref) += 2;
+            while (SYNCTEX_IS_PATH_SEPARATOR((*name_ref)[1])) {
+                ++(*name_ref);
+            }
+        } while(SYNCTEX_IS_DOT((*name_ref)[0]) && SYNCTEX_IS_PATH_SEPARATOR((*name_ref)[1]));
+        return synctex_YES;
     }
-    return name;
+    return synctex_NO;
+}
+
+/*  The base name is necessary to deal with the 2011 file naming convention...
+ *  path is a '\0' terminated string
+ *  The return value is the trailing part of the argument,
+ *  just following the first occurrence of the regexp pattern "[^|/|\].[\|/]+".*/
+const char * _synctex_base_name(const char *path) {
+    const char * ptr = path;
+    do {
+        if (synctex_ignore_leading_dot_slash_in_path(&ptr)) {
+            return ptr;
+        }
+        do {
+            if (!*(++ptr)) {
+                return path;
+            }
+        } while (!SYNCTEX_IS_PATH_SEPARATOR(*ptr));
+    } while (*(++ptr));
+    return path;
 }
 
 /*  Compare two file names, windows is sometimes case insensitive... */
 synctex_bool_t _synctex_is_equivalent_file_name(const char *lhs, const char *rhs) {
     /*  Remove the leading regex '(\./+)*' in both rhs and lhs */
-    lhs = synctex_ignore_leading_dot_slash(lhs);
-    rhs = synctex_ignore_leading_dot_slash(rhs);
-#	if SYNCTEX_WINDOWS
-    /*  On Windows, filename should be compared case insensitive.
-	 *  The characters '/' and '\' are both valid path separators.
-	 *  There will be a very serious problem concerning UTF8 because
-	 *  not all the characters must be toupper...
-	 *  I would like to have URL's instead of filenames. */
+    synctex_ignore_leading_dot_slash_in_path(&lhs);
+    synctex_ignore_leading_dot_slash_in_path(&rhs);
 next_character:
-	if(SYNCTEX_IS_PATH_SEPARATOR(*lhs)) {/*  lhs points to a path separator */
-		if(!SYNCTEX_IS_PATH_SEPARATOR(*rhs)) {/*  but not rhs */
+	if (SYNCTEX_IS_PATH_SEPARATOR(*lhs)) {/*  lhs points to a path separator */
+		if (!SYNCTEX_IS_PATH_SEPARATOR(*rhs)) {/*  but not rhs */
 			return synctex_NO;
 		}
-	} else if(SYNCTEX_IS_PATH_SEPARATOR(*rhs)) {/*  rhs points to a path separator but not lhs */
+        ++lhs;
+        ++rhs;
+        synctex_ignore_leading_dot_slash_in_path(&lhs);
+        synctex_ignore_leading_dot_slash_in_path(&rhs);
+        goto next_character;
+	} else if (SYNCTEX_IS_PATH_SEPARATOR(*rhs)) {/*  rhs points to a path separator but not lhs */
 		return synctex_NO;
-	} else if(toupper(*lhs) != toupper(*rhs)){/*  uppercase do not match */
+	} else if (SYNCTEX_ARE_PATH_CHARACTERS_EQUAL(*lhs,*rhs)){/*  uppercase do not match */
 		return synctex_NO;
 	} else if (!*lhs) {/*  lhs is at the end of the string */
 		return *rhs ? synctex_NO : synctex_YES;
@@ -180,9 +201,6 @@ next_character:
 	++lhs;
 	++rhs;
 	goto next_character;
-#	else
-    return 0 == strcmp(lhs,rhs)?synctex_YES:synctex_NO;
-#	endif
 }
 
 synctex_bool_t _synctex_path_is_absolute(const char * name) {
diff --git a/src/synctex_parser_utils.h b/src/synctex_parser_utils.h
index e67f8f5..18348aa 100644
--- a/src/synctex_parser_utils.h
+++ b/src/synctex_parser_utils.h
@@ -5,7 +5,7 @@ This file is part of the SyncTeX package.
 
 Latest Revision: Tue Jun 14 08:23:30 UTC 2011
 
-Version: 1.16
+Version: 1.17
 
 See synctex_parser_readme.txt for more details
 
@@ -61,9 +61,14 @@ authorization from the copyright holder.
 extern "C" {
 #endif
 
+#define FALSE 0
+#define TRUE !FALSE
+
 #	if _WIN32
+#       define SYNCTEX_CASE_SENSITIVE_PATH FALSE
 #		define SYNCTEX_IS_PATH_SEPARATOR(c) ('/' == c || '\\' == c)
 #	else
+#       define SYNCTEX_CASE_SENSITIVE_PATH TRUE
 #		define SYNCTEX_IS_PATH_SEPARATOR(c) ('/' == c)
 #	endif
     
@@ -73,6 +78,12 @@ extern "C" {
 #		define SYNCTEX_IS_DOT(c) ('.' == c)
 #	endif
     
+#	if SYNCTEX_CASE_SENSITIVE_PATH
+#		define SYNCTEX_ARE_PATH_CHARACTERS_EQUAL(left,right) (left != right)
+#	else
+#		define SYNCTEX_ARE_PATH_CHARACTERS_EQUAL(left,right) (toupper(left) != toupper(right))
+#	endif
+    
 /*  This custom malloc functions initializes to 0 the newly allocated memory.
  *  There is no bzero function on windows. */
 void *_synctex_malloc(size_t size);
@@ -100,6 +111,9 @@ synctex_bool_t _synctex_path_is_absolute(const char * name);
 /*	Description forthcoming...*/
 const char * _synctex_last_path_component(const char * name);
 
+/*	Description forthcoming...*/
+const char * _synctex_base_name(const char *path);
+
 /*	If the core of the last path component of src is not already enclosed with double quotes ('"')
  *  and contains a space character (' '), then a new buffer is created, the src is copied and quotes are added.
  *	In all other cases, no destination buffer is created and the src is not copied.
@@ -132,7 +146,7 @@ int _synctex_get_name(const char * output, const char * build_directory, char **
 /*  returns the correct mode required by fopen and gzopen from the given io_mode */
 const char * _synctex_get_io_mode_name(synctex_io_mode_t io_mode);
 
-const char * synctex_ignore_leading_dot_slash(const char * name);
+synctex_bool_t synctex_ignore_leading_dot_slash_in_path(const char ** name);
     
 #ifdef __cplusplus
 }
diff --git a/src/synctex_parser_version.txt b/src/synctex_parser_version.txt
index 03ff897..68209c0 100644
--- a/src/synctex_parser_version.txt
+++ b/src/synctex_parser_version.txt
@@ -1 +1 @@
-1.16
\ No newline at end of file
+1.17
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-tex/texworks.git


Reply to: