MCPcopy Create free account
hub / github.com/TeXworks/texworks / syncFromTeX

Method syncFromTeX

src/TWSynchronizer.cpp:75–120  ·  view source on GitHub ↗

virtual

Source from the content-addressed store, hash-verified

73
74//virtual
75TWSynchronizer::PDFSyncPoint TWSyncTeXSynchronizer::syncFromTeX(const TWSynchronizer::TeXSyncPoint & src, const Resolution resolution) const
76{
77 PDFSyncPoint retVal;
78 retVal.page = -1;
79
80 // Find the name SyncTeX is using for this source file...
81 const QFileInfo sourceFileInfo(src.filename);
82 QDir curDir(QFileInfo(pdfFilename()).canonicalPath());
83 SyncTeX::synctex_node_p node = SyncTeX::synctex_scanner_input(_scanner);
84 QString name;
85 bool found = false;
86 while (node) {
87 name = QString::fromLocal8Bit(SyncTeX::synctex_scanner_get_name(_scanner, SyncTeX::synctex_node_tag(node)));
88 const QFileInfo fi(curDir, name);
89 if (fi == sourceFileInfo) {
90 found = true;
91 break;
92 }
93 node = synctex_node_sibling(node);
94 }
95 if (!found)
96 return retVal;
97
98 retVal.filename = pdfFilename();
99
100 if (SyncTeX::synctex_display_query(_scanner, name.toLocal8Bit().data(), src.line, static_cast<column_type>(src.col), -1) > 0) {
101 while ((node = SyncTeX::synctex_scanner_next_result(_scanner))) {
102 if (retVal.page < 0)
103 retVal.page = SyncTeX::synctex_node_page(node);
104 if (SyncTeX::synctex_node_page(node) != retVal.page)
105 continue;
106 QRectF nodeRect(synctex_node_box_visible_h(node),
107 synctex_node_box_visible_v(node) - synctex_node_box_visible_height(node),
108 synctex_node_box_visible_width(node),
109 synctex_node_box_visible_height(node) + synctex_node_box_visible_depth(node));
110 if (!retVal.rects.contains(nodeRect))
111 retVal.rects.append(nodeRect);
112 }
113 }
114
115 // Only perform fine synchronization if requested
116 if (resolution != LineResolution)
117 _syncFromTeXFine(src, retVal, resolution);
118
119 return retVal;
120}
121
122//virtual
123TWSynchronizer::TeXSyncPoint TWSyncTeXSynchronizer::syncFromPDF(const TWSynchronizer::PDFSyncPoint & src, const Resolution resolution) const

Callers 2

syncFromSourceMethod · 0.80

Calls 14

synctex_scanner_inputFunction · 0.85
synctex_scanner_get_nameFunction · 0.85
synctex_node_tagFunction · 0.85
synctex_node_siblingFunction · 0.85
synctex_display_queryFunction · 0.85
synctex_node_pageFunction · 0.85

Tested by 1