1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
diff --git a/src/Format.cpp b/src/Format.cpp
index b7a8c20b94..f1c0ef4b4c 100644
--- a/src/Format.cpp
+++ b/src/Format.cpp
@@ -661,6 +661,27 @@ void Formats::setEditor(string const & name, string const & command)
}
+bool Formats::viewURL(docstring const & url) {
+ Format const * format = getFormat("html");
+ if (!format)
+ return false;
+
+ string command = commandPrep(format->viewer());
+
+ if (!contains(command, token_from_format))
+ command += ' ' + token_from_format;
+ command = subst(command, token_from_format, quoteName(to_utf8(url)));
+
+ LYXERR(Debug::FILES, "Executing command: " << command);
+
+ Systemcall one;
+ one.startscript(Systemcall::DontWait, command);
+
+ // we can't report any sort of error, since we aren't waiting
+ return true;
+}
+
+
bool Formats::view(Buffer const & buffer, FileName const & filename,
string const & format_name) const
{
diff --git a/src/Format.h b/src/Format.h
index cc383c0249..3f6a312913 100644
--- a/src/Format.h
+++ b/src/Format.h
@@ -187,6 +187,8 @@ public:
void setViewer(std::string const & name, std::string const & command);
///
void setEditor(std::string const & name, std::string const & command);
+ /// Currently used by hyperlink insets and GuiCitation
+ bool viewURL(docstring const & url);
/// View the given file. Buffer used for DVI's paper orientation.
bool view(Buffer const & buffer, support::FileName const & filename,
std::string const & format_name) const;
diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp
index afa49d4e35..17085d8c14 100644
--- a/src/insets/InsetHyperlink.cpp
+++ b/src/insets/InsetHyperlink.cpp
@@ -108,7 +108,10 @@ bool InsetHyperlink::getStatus(Cursor & cur, FuncRequest const & cmd,
void InsetHyperlink::viewTarget() const
{
- if (getParam("type") == "file:") {
+ if (getParam("type").empty())
+ theFormats().viewURL(getParam("target"));
+
+ else if (getParam("type") == "file:") {
FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath());
string const format = theFormats().getFormatFromFile(url);
theFormats().view(buffer(), url, format);
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index 9acf334562..bd8046bd07 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -667,6 +667,8 @@ Menuset
#
Menu "context-hyperlink"
Item "Settings...|S" "inset-settings"
+ Separator
+ Item "Open Target...|O" "inset-edit"
End
#
Index: stdinsets.inc
===================================================================
--- a/lib/layouts/stdinsets.inc (revision 28602)
+++ a/lib/layouts/stdinsets.inc (working copy)
@@ -166,7 +166,7 @@
Family typewriter
EndFont
LabelFont
- Color foreground
+ Color latex
Size Small
EndFont
BgColor listingsbg
Index: lib/ui/stdtoolbars.inc
===================================================================
--- a/lib/ui/stdtoolbars.inc (revision 29259)
+++ b/lib/ui/stdtoolbars.inc (working copy)
@@ -91,6 +91,8 @@
Item "Increase depth" "depth-increment"
Item "Decrease depth" "depth-decrement"
Separator
+ Item "Align center" "paragraph-params \align center"
+ Separator
Item "Insert figure float" "float-insert figure"
Item "Insert table float" "float-insert table"
Item "Insert label" "label-insert"
diff --git a/src/frontends/qt4/GuiCompleter.cpp b/src/frontends/qt4/GuiCompleter.cpp
index 89a889d..ac5088f 100644
--- a/src/frontends/qt4/GuiCompleter.cpp
+++ b/src/frontends/qt4/GuiCompleter.cpp
@@ -165,7 +165,7 @@ GuiCompleter::GuiCompleter(GuiWorkArea * gui, QObject * parent)
model_ = new GuiCompletionModel(this, 0);
setModel(model_);
setCompletionMode(QCompleter::PopupCompletion);
- setCaseSensitivity(Qt::CaseSensitive);
+ setCaseSensitivity(Qt::CaseInsensitive);
setWidget(gui_);
// create the popup
diff --git a/lib/ui/default.ui b/lib/ui/default.ui
index 4a1e154aab..94964d6a53 100644
--- a/lib/ui/default.ui
+++ b/lib/ui/default.ui
@@ -48,15 +48,15 @@ Include "stdtoolbars.inc"
#
Toolbars
"standard" "on,top"
- "view/update" "on,top"
+ "view/update" "off,top"
"extra" "on,top,samerow"
"review" "auto,review,top"
- "vcs" "off,top"
+ "vcs" "on,top"
"table" "auto,table,bottom"
"math_panels" "auto,math,bottom"
"math" "auto,math,bottom"
"mathmacrotemplate" "auto,mathmacrotemplate,bottom"
"ipa" "auto,ipa,bottom"
- "minibuffer" "auto,minibuffer,bottom"
+ "minibuffer" "on,bottom"
"documentation" "off,top"
End
diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp
index 323e654a41..fc339e44d2 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -1022,7 +1022,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
QString app_name = "LyX";
QCoreApplication::setOrganizationName(app_name);
QCoreApplication::setOrganizationDomain("lyx.org");
- QCoreApplication::setApplicationName(lyx_package);
+ QCoreApplication::setApplicationName("LyX");
#if QT_VERSION >= 0x050000
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
diff --git a/src/insets/ExternalSupport.cpp b/src/insets/ExternalSupport.cpp
index 3d7936abc7..07bed1d88e 100644
--- a/src/insets/ExternalSupport.cpp
+++ b/src/insets/ExternalSupport.cpp
@@ -51,7 +51,7 @@ Template const * getTemplatePtr(InsetExternalParams const & params)
void editExternal(InsetExternalParams const & params, Buffer const & buffer)
{
- theFormats().edit(buffer, params.filename,
+ theFormats().view(buffer, params.filename,
theFormats().getFormatFromFile(params.filename));
}
diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp
index 8fe7ddada2..8b2be2981d 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -4507,6 +4507,10 @@ void GuiDocument::dispatchParams()
docstring const str = current_branch + ' ' + from_ascii(x11hexname);
dispatch(FuncRequest(LFUN_SET_COLOR, str));
}
+
+ // Open insets of selected branches, close deselected ones
+ dispatch(FuncRequest(LFUN_INSET_FORALL,
+ "Branch inset-toggle assign"));
}
// rename branches in the document
executeBranchRenaming();
diff --git a/src/Converter.cpp b/src/Converter.cpp
index e272d08a64..85770dc42a 100644
--- a/src/Converter.cpp
+++ b/src/Converter.cpp
@@ -823,6 +823,14 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
if (result & LaTeX::ERRORS)
buffer.bufferErrors(terr, errorList);
+ if ((result & LaTeX::UNDEF_CIT) || (result & LaTeX::UNDEF_REF)) {
+ errorList.push_back(ErrorItem(_("Undefined reference"),
+ _("Undefined reference or citation was found during the build, please check the Log."),
+ &buffer));
+ }
+
+
+
if (!errorList.empty()) {
// We will show the LaTeX Errors GUI later which contains
// specific error messages so it would be repetitive to give
@@ -852,6 +860,7 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
int const ERROR_MASK =
LaTeX::NO_LOGFILE |
LaTeX::ERRORS |
+ LaTeX::UNDEF_REF |
LaTeX::NO_OUTPUT;
return (result & ERROR_MASK) == 0;
diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp
index df20f7b285..34a1b87721 100644
--- a/src/LaTeX.cpp
+++ b/src/LaTeX.cpp
@@ -711,6 +711,9 @@ int LaTeX::scanLogFile(TeXErrors & terr)
if (contains(token, "file:line:error style messages enabled"))
fle_style = true;
+ if (contains(token, "There were undefined citations.")||contains(token, "There were undefined references."))
+ retval |= UNDEF_REF;
+
if (prefixIs(token, "LaTeX Warning:") ||
prefixIs(token, "! pdfTeX warning")) {
diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp
index 88ee9a0320..a3ea0e141a 100644
--- a/src/insets/InsetGraphics.cpp
+++ b/src/insets/InsetGraphics.cpp
@@ -580,7 +580,7 @@ copyToDirIfNeeded(DocFileName const & file, string const & dir)
if (rtrim(only_path, "/") == rtrim(dir, "/"))
return make_pair(IDENTICAL_PATHS, FileName(file_in));
- string mangled = file.mangledFileName();
+ string mangled = file.mangledFileName(empty_string(), false, true);
if (theFormats().isZippedFile(file)) {
// We need to change _eps.gz to .eps.gz. The mangled name is
// still unique because of the counter in mangledFileName().
diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp
index df5b443381..f5a67af3cf 100644
--- a/src/support/FileName.cpp
+++ b/src/support/FileName.cpp
@@ -22,6 +22,7 @@
#include "support/Package.h"
#include "support/qstring_helpers.h"
+#include <QCryptographicHash>
#include <QDateTime>
#include <QDir>
#include <QFile>
@@ -942,6 +943,11 @@ string DocFileName::outputFileName(string const & path) const
string DocFileName::mangledFileName(string const & dir) const
+{
+ return mangledFileName(dir, true, false);
+};
+
+string DocFileName::mangledFileName(string const & dir, bool use_counter, bool encrypt_path) const
{
// Concurrent access to these variables is possible.
@@ -961,6 +967,19 @@ string DocFileName::mangledFileName(string const & dir) const
string mname = os::internal_path(name);
// Remove the extension.
mname = support::changeExtension(name, string());
+
+ if (encrypt_path) {
+ QString qname = toqstr(mname);
+#if QT_VERSION >= 0x050000
+ QByteArray hash = QCryptographicHash::hash(qname.toLocal8Bit(),QCryptographicHash::Sha256);
+#else
+ QByteArray hash = QCryptographicHash::hash(qname.toLocal8Bit(),QCryptographicHash::Sha1);
+#endif
+ hash = hash.toHex();
+ mname = fromqstr(QString(hash));
+ mname = mname + "_" + onlyFileName();
+ }
+
// The mangled name must be a valid LaTeX name.
// The list of characters to keep is probably over-restrictive,
// but it is not really a problem.
@@ -980,9 +999,12 @@ string DocFileName::mangledFileName(string const & dir) const
// Prepend a counter to the filename. This is necessary to make
// the mangled name unique.
static int counter = 0;
- ostringstream s;
- s << counter++ << mname;
- mname = s.str();
+
+ if (use_counter) {
+ ostringstream s;
+ s << counter++ << mname;
+ mname = s.str();
+ }
// MiKTeX's YAP (version 2.4.1803) crashes if the file name
// is longer than about 160 characters. MiKTeX's pdflatex
diff --git a/src/support/FileName.h b/src/support/FileName.h
index 3bfdf13f26..f46537ef33 100644
--- a/src/support/FileName.h
+++ b/src/support/FileName.h
@@ -290,6 +290,8 @@ public:
*/
std::string
mangledFileName(std::string const & dir = empty_string()) const;
+ std::string
+ mangledFileName(std::string const & dir, bool use_counter, bool encrypt_path) const;
/// \return the absolute file name without its .gz, .z, .Z extension
std::string unzippedFileName() const;
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index f4f02d2772..4dd53a0555 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -128,6 +128,7 @@ Menuset
CiteStyles
Separator
Item "Settings...|S" "inset-settings"
+ Item "Find citation|F" "inset-edit"
End
diff --git a/src/FuncCode.h b/src/FuncCode.h
index 3565cecaf9..6294258ac9 100644
--- a/src/FuncCode.h
+++ b/src/FuncCode.h
@@ -482,6 +482,7 @@ enum FuncCode
LFUN_LAYOUT_TOGGLE, // lasgouttes 20180514
// 375
LFUN_INSET_END_EDIT, // gb/rkh, 20180605
+ LFUN_CITATION_OPEN, // sanda, 20200815
LFUN_LASTACTION // end of the table
};
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index a9307c3bc6..daf5d1ce40 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -1203,6 +1203,7 @@ void LyXAction::init()
* \endvar
*/
{ LFUN_CITATION_INSERT, "citation-insert", Noop, Edit },
+ { LFUN_CITATION_OPEN, "citation-open", Noop, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_CLIPBOARD_PASTE
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index c4d7e03a0b..120c07b112 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -2225,6 +2225,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
flag.setOnOff(lyxrc.spellcheck_continuously);
break;
+ case LFUN_CITATION_OPEN:
+ enable = true;
+ break;
+
default:
return false;
}
@@ -4345,6 +4349,13 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
dr.screenUpdate(Update::Force);
break;
+ case LFUN_CITATION_OPEN: {
+ string arg = cmd.getArg(1) + " " + cmd.getArg(0);
+ //TODO: get url from citation
+ //TODO: get file from citation
+ frontend::showTarget(arg);
+ }
+
default:
// The LFUN must be for one of BufferView, Buffer or Cursor;
// let's try that:
diff --git a/src/frontends/qt4/qt_helpers.cpp b/src/frontends/qt4/qt_helpers.cpp
index d23ae9c2f9..11fd9ccc96 100644
--- a/src/frontends/qt4/qt_helpers.cpp
+++ b/src/frontends/qt4/qt_helpers.cpp
@@ -21,8 +21,11 @@
#include "BufferParams.h"
#include "FloatList.h"
+#include "FuncRequest.h"
#include "Language.h"
#include "Length.h"
+#include "LyX.h"
+#include "LyXAction.h"
#include "TextClass.h"
#include "support/convert.h"
@@ -275,6 +278,13 @@ void setSectionResizeMode(QHeaderView * view, QHeaderView::ResizeMode mode) {
view->setResizeMode(mode);
#endif
}
+
+void showTarget(string const & target){
+ //spot for generic url handling via QUrl && QDesktopServices::openUrl
+ //lyxerr<<"showtarget:"<<target<<"\n";
+ FuncRequest cmd = FuncRequest(LFUN_VC_COMMAND,"U . \"paperview " + target + "\"");
+ lyx::dispatch(cmd);
+}
} // namespace frontend
QString const qt_(char const * str, const char *)
diff --git a/src/frontends/qt4/qt_helpers.h b/src/frontends/qt4/qt_helpers.h
index 52057fc494..e81fcf7f90 100644
--- a/src/frontends/qt4/qt_helpers.h
+++ b/src/frontends/qt4/qt_helpers.h
@@ -99,6 +99,7 @@ void setSectionResizeMode(QHeaderView * view,
int logicalIndex, QHeaderView::ResizeMode mode);
void setSectionResizeMode(QHeaderView * view,
QHeaderView::ResizeMode mode);
+void showTarget(std::string const & target);
} // namespace frontend
diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp
index 3e0bd6f05f..2aaeab373f 100644
--- a/src/insets/InsetCitation.cpp
+++ b/src/insets/InsetCitation.cpp
@@ -24,6 +24,7 @@
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LaTeXFeatures.h"
+#include "LyX.h"
#include "output_xhtml.h"
#include "ParIterator.h"
#include "texstream.h"
@@ -158,13 +159,47 @@ void InsetCitation::doDispatch(Cursor & cur, FuncRequest & cmd)
cmd = FuncRequest(LFUN_INSET_MODIFY, "changetype " + newcmdname);
}
}
- // fall through
+ case LFUN_INSET_EDIT: {
+ openCitation();
+ }
+ // fall through
default:
InsetCommand::doDispatch(cur, cmd);
}
}
+void InsetCitation::openCitation(){
+ if (buffer_==NULL) return;
+ Buffer const & buf = *buffer_;
+ // Only after the buffer is loaded from file...
+ if (!buf.isFullyLoaded())
+ return;
+
+ BiblioInfo const & bi = buf.masterBibInfo();
+ if (bi.empty())
+ return;
+
+ docstring const & key = getParam("key");
+ if (key.empty())
+ return;
+
+ CiteItem ci;
+ vector<docstring> keys = getVectorFromString(key);
+ docstring year; docstring author;
+
+ int count = 0;
+ for (docstring const & kvar : keys) {
+// docstring const key_info = bi.getInfo(kvar, buffer(), ci);
+ year = bi.getYear(kvar, buffer(), false);
+ author = bi.getAuthorOrEditorList(kvar, buffer());
+ FuncRequest cmd = FuncRequest(LFUN_CITATION_OPEN, year + " " + author);
+ lyx::dispatch(cmd);
+ if (++count > 5) break;
+ }
+}
+
+
bool InsetCitation::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & status) const
{
@@ -203,6 +238,8 @@ bool InsetCitation::getStatus(Cursor & cur, FuncRequest const & cmd,
}
}
return true;
+ case LFUN_INSET_EDIT:
+ return true;
default:
return InsetCommand::getStatus(cur, cmd, status);
}
diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h
index 7962809eda..73cca71f31 100644
--- a/src/insets/InsetCitation.h
+++ b/src/insets/InsetCitation.h
@@ -92,6 +92,8 @@ public:
std::map<docstring, docstring> getQualifiedLists(docstring const p) const;
///
static bool last_literal;
+ ///
+ void openCitation();
private:
/// tries to make a pretty label and makes a basic one if not
|