aboutsummaryrefslogtreecommitdiff
path: root/desktop-utilities
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-utilities')
-rw-r--r--desktop-utilities/lumina-textedit/MainUI.cpp11
-rw-r--r--desktop-utilities/lumina-textedit/MainUI.h3
-rw-r--r--desktop-utilities/lumina-textedit/MainUI.ui12
-rw-r--r--desktop-utilities/lumina-textedit/PlainTextEditor.cpp10
-rw-r--r--desktop-utilities/lumina-textedit/syntaxSupport.cpp37
5 files changed, 50 insertions, 23 deletions
diff --git a/desktop-utilities/lumina-textedit/MainUI.cpp b/desktop-utilities/lumina-textedit/MainUI.cpp
index 53fa0ca6..d477071d 100644
--- a/desktop-utilities/lumina-textedit/MainUI.cpp
+++ b/desktop-utilities/lumina-textedit/MainUI.cpp
@@ -27,6 +27,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
ui->menuSyntax_Highlighting->addAction(smodes[i]);
}
ui->actionLine_Numbers->setChecked( settings->value("showLineNumbers",true).toBool() );
+ ui->actionWrap_Lines->setChecked( settings->value("wrapLines",true).toBool() );
//Setup any connections
connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) );
connect(ui->actionNew_File, SIGNAL(triggered()), this, SLOT(NewFile()) );
@@ -38,6 +39,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()) );
connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosed(int)) );
connect(ui->actionLine_Numbers, SIGNAL(toggled(bool)), this, SLOT(showLineNumbers(bool)) );
+ connect(ui->actionWrap_Lines, SIGNAL(toggled(bool)), this, SLOT(wrapLines(bool)) );
connect(ui->actionCustomize_Colors, SIGNAL(triggered()), this, SLOT(ModifyColors()) );
updateIcons();
//Now load the initial size of the window
@@ -115,6 +117,7 @@ void MainUI::OpenFile(QString file){
connect(edit, SIGNAL(UnsavedChanges(QString)), this, SLOT(updateTab(QString)) );
ui->tabWidget->addTab(edit, files[i].section("/",-1));
edit->showLineNumbers(ui->actionLine_Numbers->isChecked());
+ edit->setLineWrapMode( ui->actionWrap_Lines->isChecked() ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
ui->tabWidget->setCurrentWidget(edit);
edit->LoadFile(files[i]);
edit->setFocus();
@@ -153,6 +156,14 @@ void MainUI::showLineNumbers(bool show){
}
}
+void MainUI::wrapLines(bool wrap){
+ settings->setValue("wrapLines",wrap);
+ for(int i=0; i<ui->tabWidget->count(); i++){
+ PlainTextEditor *edit = static_cast<PlainTextEditor*>(ui->tabWidget->widget(i));
+ edit->setLineWrapMode( wrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
+ }
+}
+
void MainUI::ModifyColors(){
}
diff --git a/desktop-utilities/lumina-textedit/MainUI.h b/desktop-utilities/lumina-textedit/MainUI.h
index 3bb92295..64b4de3d 100644
--- a/desktop-utilities/lumina-textedit/MainUI.h
+++ b/desktop-utilities/lumina-textedit/MainUI.h
@@ -47,6 +47,7 @@ private slots:
//Other Menu Actions
void UpdateHighlighting(QAction*);
void showLineNumbers(bool);
+ void wrapLines(bool);
void ModifyColors();
//Tab Interactions
@@ -59,4 +60,4 @@ protected:
settings->setValue("lastSize", ev->size());
}
};
-#endif
+#endif \ No newline at end of file
diff --git a/desktop-utilities/lumina-textedit/MainUI.ui b/desktop-utilities/lumina-textedit/MainUI.ui
index 024d1b74..264646d7 100644
--- a/desktop-utilities/lumina-textedit/MainUI.ui
+++ b/desktop-utilities/lumina-textedit/MainUI.ui
@@ -82,6 +82,7 @@
</widget>
<addaction name="menuSyntax_Highlighting"/>
<addaction name="actionLine_Numbers"/>
+ <addaction name="actionWrap_Lines"/>
<addaction name="separator"/>
<addaction name="actionCustomize_Colors"/>
</widget>
@@ -190,6 +191,17 @@
<string>Customize Colors</string>
</property>
</action>
+ <action name="actionWrap_Lines">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Wrap Lines</string>
+ </property>
+ </action>
</widget>
<resources/>
<connections/>
diff --git a/desktop-utilities/lumina-textedit/PlainTextEditor.cpp b/desktop-utilities/lumina-textedit/PlainTextEditor.cpp
index 2c1473c8..4031eacc 100644
--- a/desktop-utilities/lumina-textedit/PlainTextEditor.cpp
+++ b/desktop-utilities/lumina-textedit/PlainTextEditor.cpp
@@ -24,6 +24,8 @@ PlainTextEditor::PlainTextEditor(QSettings *set, QWidget *parent) : QPlainTextEd
hasChanges = false;
lastSaveContents.clear();
matchleft = matchright = -1;
+ //this->setObjectName("PlainTextEditor");
+ //this->setStyleSheet("QPlainTextEdit#PlainTextEditor{ }");
SYNTAX = new Custom_Syntax(settings, this->document());
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(LNW_updateWidth()) );
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(LNW_highlightLine()) );
@@ -145,8 +147,8 @@ void PlainTextEditor::highlightMatch(QChar ch, bool forward, int fromPos){
QList<QTextEdit::ExtraSelection> sels = this->extraSelections();
if(matchleft>=0){
QTextEdit::ExtraSelection sel;
- if(matchright>=0){ sel.format.setBackground(Qt::darkGreen); }
- else{ sel.format.setBackground(Qt::darkRed); }
+ if(matchright>=0){ sel.format.setBackground( QColor(settings->value("colors/bracket-found").toString()) ); }
+ else{ sel.format.setBackground( QColor(settings->value("colors/bracket-missing").toString()) ); }
QTextCursor cur = this->textCursor();
cur.setPosition(matchleft);
if(forward){ cur.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); }
@@ -156,8 +158,8 @@ void PlainTextEditor::highlightMatch(QChar ch, bool forward, int fromPos){
}
if(matchright>=0){
QTextEdit::ExtraSelection sel;
- if(matchleft>=0){ sel.format.setBackground(Qt::darkGreen); }
- else{ sel.format.setBackground(Qt::darkRed); }
+ if(matchleft>=0){ sel.format.setBackground( QColor(settings->value("colors/bracket-found").toString()) ); }
+ else{ sel.format.setBackground( QColor(settings->value("colors/bracket-missing").toString()) ); }
QTextCursor cur = this->textCursor();
cur.setPosition(matchright);
if(!forward){ cur.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); }
diff --git a/desktop-utilities/lumina-textedit/syntaxSupport.cpp b/desktop-utilities/lumina-textedit/syntaxSupport.cpp
index 521a194f..2d00201f 100644
--- a/desktop-utilities/lumina-textedit/syntaxSupport.cpp
+++ b/desktop-utilities/lumina-textedit/syntaxSupport.cpp
@@ -19,7 +19,8 @@ QStringList Custom_Syntax::knownColors(){
QStringList avail;
//Standard colors
avail << "keyword" << "altkeyword" << "class" << "text" << "function" << "comment";
-
+ //Bracket/parenthesis/brace matching
+ avail << "bracket-found" << "bracket-missing";
return avail;
}
@@ -31,6 +32,8 @@ void Custom_Syntax::SetupDefaultColors(QSettings *settings){
settings->setValue("colors/text", QColor(Qt::darkMagenta).name() );
settings->setValue("colors/function", QColor(Qt::darkCyan).name() );
settings->setValue("colors/comment", QColor(Qt::darkGreen).name() );
+ settings->setValue("colors/bracket-found", QColor(Qt::green).name() );
+ settings->setValue("colors/bracket-missing", QColor(Qt::red).name() );
}
QString Custom_Syntax::ruleForFile(QString filename){
@@ -135,7 +138,7 @@ void Custom_Syntax::loadRules(QString type){
rules << rule;
}
//Directives
- /*keywords.clear();
+ keywords.clear();
keywords << "image" << "figure" << "contents" << "container" << "rubric" << "topic" << "sidebar" \
<< "parsed-literal" << "epigraph" << "highlights" << "pull-quote" << "compound" << "table" << "csv-table" \
<< "list-table" << "raw" << "include"<< "class" << "meta" << "title" << "default-role" << "role";
@@ -143,27 +146,25 @@ void Custom_Syntax::loadRules(QString type){
for(int i=0; i<keywords.length(); i++){
rule.pattern = QRegExp("\\b"+keywords[i]+"::\\b"); //turn each keyword into a QRegExp and insert the rule
rules << rule;
- }*/
+ }
//Reset the font color
- // Emphasis
- /*rule.format = QTextCharFormat();
- rule.format.setFontItalic(true);
- rule.pattern = QRegExp("\\b\\**\\*\\b");
- rules << rule;
+ rule.format = QTextCharFormat();
// Strong Emphasis
rule.format.setFontItalic(false);
rule.format.setFontWeight(QFont::Bold);
- rule.pattern = QRegExp("\\b\\*\\**\\*\\*\\b");
+ rule.pattern = QRegExp("\\b[*]{2}.*[*]{2}\\b");
+ rules << rule;
+ // Emphasis
+ rule.format.setFontItalic(true);
+ rule.format.setFontWeight(QFont::Normal);
+ rule.pattern = QRegExp("\\b[*].+[*]\\b");
rules << rule;
// Code Sample
+ rule.format.setFontItalic(false);
rule.format.setFontWeight(QFont::Light);
rule.format.setFontFixedPitch(true);
- rule.pattern = QRegExp("\\b\\`\\`*\\`\\`\\b");
+ rule.pattern = QRegExp("\\b`{2}.*`{2}\\b");
rules << rule;
- //Class Names
- //rule.format.setForeground( QColor(settings->value("colors/class").toString()) );
- //rule.pattern = QRegExp("\\bQ[A-Za-z]+\\b");
- //rules << rule;
//Quotes
rule.format.setForeground( QColor(settings->value("colors/text").toString()) );
rule.format.setFontWeight(QFont::Normal);
@@ -172,11 +173,11 @@ void Custom_Syntax::loadRules(QString type){
//Functions
rule.format.setForeground( QColor(settings->value("colors/function").toString()) );
rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()");
- rules << rule;*/
+ rules << rule;
//Comment (single line)
- //rule.format.setForeground( QColor(settings->value("colors/comment").toString()) );
- //rule.pattern = QRegExp("\\b\\.\\.\\ [^\n]*");
- //rules << rule;
+ rule.format.setForeground( QColor(settings->value("colors/comment").toString()) );
+ rule.pattern = QRegExp("\\b[.]{2}[^\n]*");
+ rules << rule;
//Comment (multi-line)
//SyntaxRuleSplit srule;
//srule.format = rule.format; //re-use the single-line comment format
bgstack15