Commit a34e62b0 authored by Atsuhito Kohda's avatar Atsuhito Kohda

Imported Upstream version 0.5~svn1026

parent 99160cd3
......@@ -36,6 +36,10 @@ QMAKE_CXXFLAGS += -DHAVE_POPPLER_XPDF_HEADERS
# maximum compression for resources (unless that only produces a 5% size decrease)
QMAKE_RESOURCE_FLAGS += -threshold 5 -compress 9
# turn on advanced warnings to check code quality
# (Note: Qt's own header files produce lots of "long long" warnings, so we disable those)
QMAKE_CXXFLAGS_WARN_ON += -Wall -pedantic -ansi -Wno-long-long
# avoid warnings about "#pragma mark" on non-Mac/non-XCode systems
QMAKE_CXXFLAGS_WARN_ON += -Wno-unknown-pragmas
......@@ -171,8 +175,10 @@ HEADERS += src/TWApp.h \
src/HardWrapDialog.h \
src/ResourcesDialog.h \
src/ScriptManager.h \
src/ClosableTabWidget.h \
src/ConfirmDelete.h \
src/TWVersion.h \
src/TWTextCodecs.h \
src/SvnRev.h \
src/synctex_parser.h \
src/synctex_parser_utils.h \
......@@ -201,6 +207,7 @@ SOURCES += src/main.cpp \
src/TWScript.cpp \
src/TWScriptAPI.cpp \
src/TeXDocument.cpp \
src/ClosableTabWidget.cpp \
src/CommandlineParser.cpp \
src/CompletingEdit.cpp \
src/TeXHighlighter.cpp \
......@@ -210,6 +217,7 @@ SOURCES += src/main.cpp \
src/FindDialog.cpp \
src/PrefsDialog.cpp \
src/TemplateDialog.cpp \
src/TWTextCodecs.cpp \
src/HardWrapDialog.cpp \
src/ResourcesDialog.cpp \
src/ScriptManager.cpp \
......
......@@ -25,11 +25,13 @@ cleanup-patterns: $jobname.4ct $jobname.4tc
#
# file-open-filter: TeX documents (*.tex)
# file-open-filter: LaTeX documents (*.ltx)
# file-open-filter: Log files (*.log *.blg)
# file-open-filter: BibTeX databases (*.bib)
# file-open-filter: Style files (*.sty)
# file-open-filter: Class files (*.cls)
# file-open-filter: Documented macros (*.dtx)
# file-open-filter: Auxiliary files (*.aux *.toc *.lot *.lof *.nav *.out *.snm *.ind *.idx *.bbl *.log)
# file-open-filter: Auxiliary files (*.aux *.toc *.lot *.lof *.nav *.out *.snm *.ind *.idx *.bbl *.brf)
# file-open-filter: Text files (*.txt)
# file-open-filter: PDF documents (*.pdf)
# file-open-filter: All files (*.* *)
# file-open-filter: All files (*)
......@@ -2,8 +2,8 @@
// Title: Errors, warnings, badboxes
// Description: Looks for errors, warnings or badboxes in the LaTeX terminal output
// Author: Jonathan Kew, Stefan Löffler, Antonio Macrì, Henrik Skov Midtiby
// Version: 0.8.2
// Date: 2012-03-26
// Version: 0.8.3
// Date: 2012-08-21
// Script-Type: hook
// Hook: AfterTypeset
......@@ -52,7 +52,7 @@ if(typeof(String.prototype.trimRight) == "undefined")
}
// Enums
var Severity = { BadBox:0, Warning:1, Error:2 };
var Severity = { BadBox:0, Warning:1, Error:2, Debug:3 };
var SortBy = { Severity:0, Occurrence:1 };
// Constructor
......@@ -108,11 +108,12 @@ function LogParser()
// Additionally, it recognizes other warnings like "LaTeX Font Warning: ...\n(Font) ...".
// The macro \GenericWarning does not produce formatted output, so it is impossible
// to match it. We need to look for output generated by higher level commands.
Regex: new RegExp("^((?:Class|Package|LaTeX) ([^\\s]+) Warning: .+\n)(?:\\(\\2\\)\\s([^\n]+)\n)*(?!\\(\\2\\))"),
Regex: new RegExp("^(?:Class|Package|LaTeX) ([^\\s]+) Warning: .+\n(?:.+\\.\n|(?:\\(\\1\\)\\s.+\n)*)"),
Callback: function(m, f) {
// We remove "\n(<name>) " from description:
var desc = m[0].replace(new RegExp("\\(" + m[2] + "\\)\\s([^\n]+)\n", "g"), " $1 ").replace(/\s+/g, " ").trim();
var row = /on input line (\d+)\./.exec(m[0]);
var desc = m[0].replace(new RegExp("\\(" + m[1] + "\\)\\s(.+)\n", "g"), " $1 ")
.replace(/\n/g, "").replace(/\s+/g, " ").trim();
var row = /on input line (\d+)\./.exec(desc);
return new Result(Severity.Warning, f, row ? row[1] : 0, desc);
}
},
......@@ -123,18 +124,39 @@ function LogParser()
// a dot followed by a newline.
Regex: new RegExp("^LaTeX Warning: (?:(?!\\.\n).|\n)+\\.\n"),
Callback: function(m, f) {
m[0] = m[0].replace(/\n/g, "").trim();
m[0] = m[0].replace(/\n/g, "").replace(/\s+/g, " ").trim();
var row = /on input line (\d+)\./.exec(m[0]);
return new Result(Severity.Warning, f, row ? row[1] : 0, m[0]);
}
},
{
// This pattern recognizes badboxes on one, two or more lines.
Regex: new RegExp("^((?:Under|Over)full \\\\[hv]box\\s*\\([^)]+\\) in paragraph at lines (\\d+)--\\d+\n)((?:.{" + max_print_line + "}\n)*)(.+)"),
// This pattern recognizes badboxes in paragraphs with context given on one, two or more lines.
Regex: new RegExp("^((?:Under|Over)full \\\\hbox\\s*\\([^)]+\\) in paragraph at lines (\\d+)--\\d+\n)((?:.{" + max_print_line + "}\n)*)(.+)"),
Callback: function(m, f) {
return new Result(Severity.BadBox, f, m[2], m[1] + m[3].replace(/\n/g, '') + m[4].trimRight());
}
},
{
// This pattern recognizes badboxes without context, but with line numbers
Regex: new RegExp("^(?:Under|Over)full \\\\[hv]box\\s*\\([^)]+\\) (?:detected at line (\\d+)|in alignment at lines (\\d+)--\\d+)\n"),
Callback: function(m, f) {
return new Result(Severity.BadBox, f, m[1] || m[2], m[0].trimRight());
}
},
{
// This pattern recognizes badboxes without context and line numbers
Regex: new RegExp("^(?:Under|Over)full \\\\[hv]box\\s*\\([^)]+\\) has occurred while \\\\output is active\n"),
Callback: function(m, f) {
return new Result(Severity.BadBox, f, 0, m[0].trimRight());
}
},
{
// \show and \showthe
Regex: new RegExp("^>\\s(.+(?:\\.|=macro:)\n(?:.*\n)*?l\\.(\\d+)\\s.*)\n"),
Callback: function(m, f) {
return new Result(Severity.Debug, f, m[2], m[1]);
}
},
{
// At last, we check for a rerun of LaTeX caused by some Latexmk's rule
Regex: new RegExp("^Latexmk: applying rule"),
......@@ -225,8 +247,9 @@ LogParser.MatchNewFile = (function()
// * /abc, "/abc"
// * .\abc, ".\abc"
// * C:\abc, "C:\abc"
// * C:/abc, "C:/abc"
// * \\server\abc, "\\server\abc"
var fileRegexp = new RegExp('^\\("((?:\\./|/|\\.\\\\|[a-zA-Z]:\\\\|\\\\\\\\)(?:[^"]|\n)+)"|^\\(((?:\\./|/|\\.\\\\|[a-zA-Z]:\\\\|\\\\\\\\)[^ ()\n]+)');
var fileRegexp = new RegExp('^\\("((?:\\./|/|\\.\\\\|[a-zA-Z]:\\\\|[a-zA-Z]:/|\\\\\\\\)(?:[^"]|\n)+)"|^\\(((?:\\./|/|\\.\\\\|[a-zA-Z]:\\\\|[a-zA-Z]:/|\\\\\\\\)[^ ()\n]+)');
var fileContinuingRegexp = new RegExp('[/\\\\ ()\n]');
var filenameRegexp = new RegExp("[^\\.]\\.[a-zA-Z0-9]{1,4}$");
var parenRegexp = new RegExp("\\((?:[^()]|\n)*\\)");
......@@ -308,7 +331,10 @@ LogParser.MatchNewFile = (function()
else {
if (existence == EXISTS)
break;
if (existence == MAYEXIST && filenameRegexp.test(match[2])) {
if (existence == MAYEXIST && filenameRegexp.test(match[2]) &&
// It seems that after a file may only be a newline
// or a space followed by another file \( or a page \[
(m[0] == '\n' || m[0] == ' ' && /^\s*[([]/.test(output))) {
svmatch = match[2];
svoutput = output;
}
......@@ -360,10 +386,10 @@ LogParser.prototype.WarnAuxFiles = function()
LogParser.prototype.GenerateReport = function(onlyTable)
{
if (this.Results.length > 0) {
var counters = [ 0, 0, 0 ];
var counters = [ 0, 0, 0, 0 ];
var html = "<table border='0' cellspacing='0' cellpadding='4'>";
if (this.Settings.SortBy == SortBy.Severity) {
var htmls = [ "", "", "" ];
var htmls = [ "", "", "", "" ];
for(var i = 0, len = this.Results.length; i < len; i++) {
var result = this.Results[i];
htmls[result.Severity] += LogParser.GenerateResultRow(result);
......@@ -411,7 +437,7 @@ LogParser.EscapeHtml = function(str)
LogParser.GenerateResultRow = (function()
{
var colors = [ "#8080FF", "#F8F800", "#F80000" ];
var colors = [ "#8080FF", "#F8F800", "#F80000", "#00F800" ];
var getFilename = new RegExp("[^\\\\/]+$");
return function(result) {
var html = '';
......
/*
This is part of TeXworks, an environment for working with TeX documents
Copyright (C) 2007-2012 Jonathan Kew, Stefan Löffler, Charlie Sharpsteen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
For links to further information, or to contact the authors,
see <http://www.tug.org/texworks/>.
*/
#include "ClosableTabWidget.h"
#include <QStyle>
#include <QTabBar>
ClosableTabWidget::ClosableTabWidget(QWidget * parent /* = NULL */)
: QTabWidget(parent)
{
_closeButton = new QToolButton(this);
Q_ASSERT(_closeButton != NULL);
_closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
_closeButton->setCursor(Qt::ArrowCursor);
// _closeButton->setStyleSheet(QString::fromUtf8("QToolButton { border: none; padding: 0px; }"));
connect(_closeButton, SIGNAL(clicked()), this, SIGNAL(requestClose()));
}
void ClosableTabWidget::resizeEvent(QResizeEvent * e)
{
// Let the QTabWidget handle proper resizing of the widgets inside the tabs
QTabWidget::resizeEvent(e);
// Position the close button on the right
Q_ASSERT(_closeButton != NULL);
QSize b = _closeButton->sizeHint();
_closeButton->move(rect().right() - b.width(), 0);
// Ensure that the tab bar is small enough not to overlap the close button
Q_ASSERT(tabBar() != NULL);
tabBar()->setMaximumWidth(rect().right() - b.width());
}
/*
This is part of TeXworks, an environment for working with TeX documents
Copyright (C) 2007-2012 Jonathan Kew, Stefan Löffler, Charlie Sharpsteen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
For links to further information, or to contact the authors,
see <http://www.tug.org/texworks/>.
*/
#ifndef __CLOSABLE_TAB_WIDGET_H
#define __CLOSABLE_TAB_WIDGET_H
#include <QTabWidget>
#include <QToolButton>
// The ClosableTabWidget class is adapted from code presented by Girish
// Ramakrishnan in a Qt Labs post:
//
// http://labs.qt.nokia.com/2007/06/06/lineedit-with-a-clear-button
class ClosableTabWidget : public QTabWidget
{
Q_OBJECT
public:
ClosableTabWidget(QWidget * parent = NULL);
virtual ~ClosableTabWidget() { }
signals:
void requestClose();
protected:
void resizeEvent(QResizeEvent * e);
QToolButton * _closeButton;
};
#endif // !defined(__CLOSABLE_TAB_WIDGET_H)
......@@ -55,25 +55,14 @@ CompletingEdit::CompletingEdit(QWidget *parent)
pHunspell(NULL), spellingCodec(NULL)
{
if (sharedCompleter == NULL) { // initialize shared (static) members
qreal bgR, bgG, bgB;
qreal fgR, fgG, fgB;
sharedCompleter = new QCompleter(qApp);
sharedCompleter->setCompletionMode(QCompleter::InlineCompletion);
sharedCompleter->setCaseSensitivity(Qt::CaseInsensitive);
loadCompletionFiles(sharedCompleter);
palette().color(QPalette::Active, QPalette::Base).getRgbF(&bgR, &bgG, &bgB);
palette().color(QPalette::Active, QPalette::Text).getRgbF(&fgR, &fgG, &fgB);
currentCompletionFormat = new QTextCharFormat;
currentCompletionFormat->setBackground(QColor::fromRgbF(.75 * bgR + .25 * fgR, .75 * bgG + .25 * fgG, .75 * bgB + .25 * fgB));
braceMatchingFormat = new QTextCharFormat;
braceMatchingFormat->setBackground(QColor("orange"));
currentLineFormat = new QTextCharFormat;
currentLineFormat->setBackground(QColor::fromRgbF(.9 * bgR + .1 * fgR, .9 * bgG + .1 * fgG, .9 * bgB + .1 * fgB));
currentLineFormat->setProperty(QTextFormat::FullWidthSelection, true);
QSETTINGS_OBJECT(settings);
highlightCurrentLine = settings.value("highlightCurrentLine", true).toBool();
......@@ -96,6 +85,31 @@ CompletingEdit::CompletingEdit(QWidget *parent)
cursorPositionChangedSlot();
updateLineNumberAreaWidth(0);
updateColors();
}
void CompletingEdit::updateColors()
{
Q_ASSERT(currentCompletionFormat != NULL);
Q_ASSERT(braceMatchingFormat != NULL);
Q_ASSERT(currentLineFormat != NULL);
Q_ASSERT(lineNumberArea != NULL);
qreal bgR, bgG, bgB;
qreal fgR, fgG, fgB;
palette().color(QPalette::Active, QPalette::Base).getRgbF(&bgR, &bgG, &bgB);
palette().color(QPalette::Active, QPalette::Text).getRgbF(&fgR, &fgG, &fgB);
currentCompletionFormat->setBackground(QColor::fromRgbF(.75 * bgR + .25 * fgR, .75 * bgG + .25 * fgG, .75 * bgB + .25 * fgB));
braceMatchingFormat->setBackground(QColor("orange"));
currentLineFormat->setBackground(QColor::fromRgbF(.9 * bgR + .1 * fgR, .9 * bgG + .1 * fgG, .9 * bgB + .1 * fgB));
currentLineFormat->setProperty(QTextFormat::FullWidthSelection, true);
palette().color(QPalette::Window).getRgbF(&bgR, &bgG, &bgB);
palette().color(QPalette::Text).getRgbF(&fgR, &fgG, &fgB);
lineNumberArea->setBgColor(QColor::fromRgbF(0.75 * bgR + 0.25 * fgR, 0.75 * bgG + 0.25 * fgG, 0.75 * bgB + 0.25 * fgB));
}
CompletingEdit::~CompletingEdit()
......@@ -1085,6 +1099,11 @@ int CompletingEdit::lineNumberAreaWidth()
return space;
}
bool CompletingEdit::getLineNumbersVisible() const
{
return lineNumberArea->isVisible();
}
void CompletingEdit::updateLineNumberAreaWidth(int /* newBlockCount */)
{
if (lineNumberArea->isVisible()) {
......@@ -1117,8 +1136,10 @@ void CompletingEdit::resizeEvent(QResizeEvent *e)
void CompletingEdit::lineNumberAreaPaintEvent(QPaintEvent *event)
{
Q_ASSERT(lineNumberArea != NULL);
QPainter painter(lineNumberArea);
painter.fillRect(event->rect(), Qt::lightGray);
painter.fillRect(event->rect(), lineNumberArea->bgColor());
QTextBlock block = document()->begin();
int blockNumber = 1;
......@@ -1150,6 +1171,10 @@ bool CompletingEdit::event(QEvent *e)
// but don't know how to get that from the event :(
emit updateRequest(viewport()->rect(), 0);
}
// Alternatively, we could use QEvent::ApplicationPaletteChange if we'd
// derive the colors from the application's palette
if (e->type() == QEvent::PaletteChange)
updateColors();
return QTextEdit::event(e);
}
......
......@@ -31,6 +31,7 @@
class QCompleter;
class QStandardItemModel;
class QTextCodec;
class LineNumberArea;
class CompletingEdit : public QTextEdit
{
......@@ -48,7 +49,7 @@ public:
void lineNumberAreaPaintEvent(QPaintEvent *event);
int lineNumberAreaWidth();
bool getLineNumbersVisible() const { return lineNumberArea->isVisible(); }
bool getLineNumbersVisible() const;
QString getIndentMode() const {
return autoIndentMode >= 0 && autoIndentMode < autoIndentModes().size() ?
......@@ -103,6 +104,8 @@ private slots:
void updateLineNumberArea(const QRect&, int);
private:
void updateColors();
void setCompleter(QCompleter *c);
void showCompletion(const QString& completion, int insOffset = -1);
......@@ -175,7 +178,7 @@ private:
QTextCursor currentCompletionRange;
QWidget *lineNumberArea;
LineNumberArea *lineNumberArea;
static QTextCharFormat *currentCompletionFormat;
static QTextCharFormat *braceMatchingFormat;
......@@ -200,6 +203,9 @@ public:
return QSize(editor->lineNumberAreaWidth(), 0);
}
QColor bgColor() const { return _bgColor; }
void setBgColor(const QColor color) { _bgColor = color; }
protected:
void paintEvent(QPaintEvent *event) {
editor->lineNumberAreaPaintEvent(event);
......@@ -207,6 +213,7 @@ protected:
private:
CompletingEdit *editor;
QColor _bgColor;
};
#endif // COMPLETING_EDIT_H
#define SVN_REVISION 1007
#define SVN_REVISION_STR "1007"
#define SVN_REVISION 1026
#define SVN_REVISION_STR "1026"
......@@ -30,6 +30,7 @@
#include "TWVersion.h"
#include "SvnRev.h"
#include "ResourcesDialog.h"
#include "TWTextCodecs.h"
#ifdef Q_WS_WIN
#include "DefaultBinaryPathsWin.h"
......@@ -102,6 +103,8 @@ TWApp::~TWApp()
void TWApp::init()
{
customTextCodecs << new MacCentralEurRomanCodec();
QIcon appIcon;
#ifdef Q_WS_X11
// The Compiz window manager doesn't seem to support icons larger than
......
......@@ -264,7 +264,8 @@ private:
TWScriptManager *scriptManager;
QHash<QString, QVariant> m_globals;
QHash<QString, QVariant> m_globals;
QList<QTextCodec*> customTextCodecs;
#ifdef Q_WS_WIN
HWND messageTargetWindow;
......
......@@ -51,11 +51,11 @@ public:
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);
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
*
......
......@@ -22,6 +22,7 @@
#include "TWScriptAPI.h"
#include "TWSystemCmd.h"
#include "TWUtils.h"
#include "TWApp.h"
#include <QObject>
#include <QString>
......@@ -369,3 +370,20 @@ QMap<QString, QVariant> TWScriptAPI::getDictionaryList(const bool forceReload /*
}
//////////////// Wrapper around selected TWUtils functions ////////////////
// Wrapper around TWApp::getEngineList()
Q_INVOKABLE
QList<QVariant> TWScriptAPI::getEngineList() const
{
QList<QVariant> retVal;
const QList<Engine> engines = TWApp::instance()->getEngineList();
foreach (const Engine& e, engines) {
QMap<QString, QVariant> s;
s["name"] = e.name();
retVal.append(s);
}
return retVal;
}
......@@ -33,10 +33,10 @@ class TWScriptAPI : public QObject
{
Q_OBJECT
Q_PROPERTY(QObject* app READ GetApp);
Q_PROPERTY(QObject* target READ GetTarget);
Q_PROPERTY(QVariant result READ GetResult WRITE SetResult);
Q_PROPERTY(QObject * script READ GetScript);
Q_PROPERTY(QObject* app READ GetApp)
Q_PROPERTY(QObject* target READ GetTarget)
Q_PROPERTY(QVariant result READ GetResult WRITE SetResult)
Q_PROPERTY(QObject * script READ GetScript)
public:
TWScriptAPI(TWScript* script, QObject* twapp, QObject* ctx, QVariant& res);
......@@ -175,6 +175,11 @@ public:
Q_INVOKABLE
QMap<QString, QVariant> getDictionaryList(const bool forceReload = false);
//////////////// Wrapper around selected TWUtils functions ////////////////
// Wrapper around TWApp::getEngineList()
// Currently, only the name is returned
Q_INVOKABLE
QList<QVariant> getEngineList() const;
protected:
TWScript* m_script;
......
/*
This is part of TeXworks, an environment for working with TeX documents
Copyright (C) 2007-2012 Jonathan Kew, Stefan Löffler, Charlie Sharpsteen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
For links to further information, or to contact the authors,
see <http://www.tug.org/texworks/>.
*/
#include <TWTextCodecs.h>
// NOTE: The convert*Unicode functions are modeled after those in the files in
// <Qt>/src/corelib/codecs/
// This data is extracted from http://en.wikipedia.org/w/index.php?title=Macintosh_Central_European_encoding&oldid=450446783
ushort MacCentralEurRomanCodes[] = {
0x00C4, 0x0100, 0x0101, 0x00C9, 0x0104, 0x00D6, 0x00DC, 0x00E1,
0x0105, 0x010C, 0x00E4, 0x010D, 0x0106, 0x0107, 0x00E9, 0x0179,
0x017A, 0x010E, 0x00ED, 0x010F, 0x0112, 0x0113, 0x0116, 0x00F3,
0x0117, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x011A, 0x011B, 0x00FC,
0x2020, 0x00B0, 0x0118, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
0x00AE, 0x00A9, 0x2122, 0x0119, 0x00A8, 0x2260, 0x0123, 0x012E,
0x012F, 0x012A, 0x2264, 0x2265, 0x012B, 0x0136, 0x2202, 0x2211,
0x0142, 0x013B, 0x013C, 0x013D, 0x013E, 0x0139, 0x013A, 0x0145,
0x0146, 0x0143, 0x00AC, 0x221A, 0x0144, 0x0147, 0x2206, 0x00AB,
0x00BB, 0x2026, 0x00A0, 0x0148, 0x0150, 0x00D5, 0x0151, 0x014C,
0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
0x014D, 0x0154, 0x0155, 0x0158, 0x2039, 0x203A, 0x0159, 0x0156,
0x0157, 0x0160, 0x201A, 0x201E, 0x0161, 0x015A, 0x015B, 0x00C1,
0x0164, 0x0165, 0x00CD, 0x017D, 0x017E, 0x016A, 0x00D3, 0x00D4,
0x016B, 0x016E, 0x00DA, 0x016F, 0x0170, 0x0171, 0x0172, 0x0173,
0x00DD, 0x00FD, 0x0137, 0x017B, 0x0141, 0x017C, 0x0122, 0x02C7
};
QList<QByteArray> MacCentralEurRomanCodec::aliases() const
{
QList<QByteArray> list;
list << "MacCentralEuropeanRoman" << "MacCentralEurRoman";
return list;
}
QByteArray MacCentralEurRomanCodec::convertFromUnicode(const QChar * input, int length, ConverterState * state) const
{
const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
QByteArray r(length, Qt::Uninitialized);
char *d = r.data();
int invalid = 0;
int i, j;
for (i = 0; i < length; ++i) {
uchar c;
ushort uc = input[i].unicode();
if (uc < 0x0080)
c = (unsigned char)uc;
else {
for (j = 0; j < 128; ++j) {
if (MacCentralEurRomanCodes[j] == uc) {
c = j + 0x80;
break;
}
}
if (j >= 128) {
c = replacement;
++invalid;
}
}
d[i] = (char)c;
}
if (state) {
state->remainingChars = 0;
state->invalidChars += invalid;
}
return r;
}
QString MacCentralEurRomanCodec::convertToUnicode(const char * chars, int len, ConverterState * state) const
{
Q_UNUSED(state)
if (chars == 0)
return QString();
QString str = QString::fromLatin1(chars, len);
QChar *uc = str.data();
while(len--) {
// NOTE: uc->unicode() should always be <= 0xff!
if (uc->unicode() >= 0x80 && uc->unicode() <= 0xff)
*uc = MacCentralEurRomanCodes[uc->unicode() - 0x80];
uc++;
}
return str;
}
/*
This is part of TeXworks, an environment for working with TeX documents
Copyright (C) 2007-2012 Jonathan Kew, Stefan Löffler, Charlie Sharpsteen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
For links to further information, or to contact the authors,
see <http://www.tug.org/texworks/>.
*/
#ifndef TWTextCodecs_H
#define TWTextCodecs_H
#include <QTextCodec>
class MacCentralEurRomanCodec : public QTextCodec
{
public:
MacCentralEurRomanCodec() : QTextCodec() { }
virtual ~MacCentralEurRomanCodec() { }
// NOTE: The mib number is arbitrary since this encoding is not in the IANA
// list (http://www.iana.org/assignments/character-sets).
int mibEnum() const { return -4000; }
QByteArray name() const { return "Mac Central European Roman"; }
QList<QByteArray> aliases() const;
protected:
QByteArray convertFromUnicode(const QChar * input, int length, ConverterState * state) const;
QString convertToUnicode(const char * chars, int len, ConverterState * state) const;
};
#endif // !defined(TWTextCodecs)
......@@ -481,12 +481,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("Log files (*.log *.blg)");
*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)");
*filters << QObject::tr("Auxiliary files (*.aux *.toc *.lot *.lof *.nav *.out *.snm *.ind *.idx *.bbl *.brf)");
*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
......
......@@ -102,6 +102,7 @@ void TeXDocument::init()
process = NULL;
highlighter = NULL;
pHunspell = NULL;
utf8BOM = false;
#ifdef Q_WS_WIN