Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemment dark mode #411

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
476b884
Inital implementation of dark mode, based on QDarkStyleSheet
Jun 28, 2023
0edfd02
Refactoring editor manager, make it easy to support dark mode
Jun 28, 2023
701756d
Inital verion of dark mode, UI dark mode is OK and language dark mode…
wayne-zhang Jun 30, 2023
608ae81
add makefile lua file ignored for unknow reason
wayne-zhang Jun 30, 2023
eb2ad77
Fixed C++ language family space bg colours dark mode issues; Dark the…
wayne-zhang Jul 2, 2023
9bf895d
Share dark bg/fg color by editor & languate lua scripts
wayne-zhang Jul 3, 2023
9971592
Add dark mode in Settings UI
wayne-zhang Jul 5, 2023
554cede
fix active tabbar foreground color issue in dark mode
wayne-zhang Jul 6, 2023
a1f3684
Add ThemeColors.h to share theme colors defination
wayne-zhang Jul 6, 2023
5fb2465
Lua console supports dark mode
wayne-zhang Jul 6, 2023
3d69878
Lua console dark theme tweak
wayne-zhang Jul 7, 2023
147a664
Lua console further tweak
wayne-zhang Jul 7, 2023
ccf17a8
Fix edtiors first character cut-off issue in dark mode
wayne-zhang Jul 9, 2023
ed7dcf4
Fix editor active tab bar text color
wayne-zhang Jul 9, 2023
a97f66e
fix a typo
wayne-zhang Jul 9, 2023
a835b49
Tweak C++ family languages Lua configurations on dark mode, make keyw…
wayne-zhang Jul 10, 2023
b02185b
fix languages sub menu background color in dark mode
wayne-zhang Jul 11, 2023
612209d
fix languages sub menu background color in dark mode - version 2
wayne-zhang Jul 11, 2023
46d265f
fix comment typo/spell
wayne-zhang Jul 11, 2023
849d46a
Refactoring dark mode CSS, move NotepadNext tweak from qdarkstyle to …
wayne-zhang Jul 12, 2023
65cb381
Linux in dark mode 'Close without Saving' button width tweak
wayne-zhang Jul 14, 2023
b5804ca
Fixed SQL and ActionScript background color issues in dark mode; Dark…
wayne-zhang Jul 14, 2023
740a96c
Fix typo/spell in comments
wayne-zhang Jul 14, 2023
d8c51c8
use the language lua lexers for both dark and light mode
wayne-zhang Jul 14, 2023
ea12334
Fixed missing arg
wayne-zhang Jul 14, 2023
56c1024
fixed langages merge errors, but function broken
wayne-zhang Jul 15, 2023
76288a7
Fixed languages lua template merge issue
wayne-zhang Jul 15, 2023
39cabe5
setLanguageColors method doc
wayne-zhang Jul 15, 2023
5eb828d
Fix spell/typo
wayne-zhang Jul 16, 2023
757f19d
refactoring colors and color utilies
wayne-zhang Jul 17, 2023
9e47570
Refactoring
wayne-zhang Jul 17, 2023
9046878
Fix spells reported by Github builder
wayne-zhang Jul 18, 2023
2abe1aa
dark mode tab title padding & icon size tweak
wayne-zhang Jul 19, 2023
f167257
Dark mode editor issues fix
wayne-zhang Jul 21, 2023
37647a9
Fixed dark mode active tab color issues
wayne-zhang Jul 21, 2023
4699cfe
Fix tab's title/text elided when lots of files/tabs opened
wayne-zhang Jul 23, 2023
44babd6
Merge branch 'tabs-enhancement' into dark-mode-v2
wayne-zhang Jul 23, 2023
c64bee1
Merge branch 'upstream-master'
wayne-zhang Dec 3, 2023
b246793
Fix merge issue of upstream master merge
wayne-zhang Dec 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions src/NotepadNext/DockedEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "DockWidgetTab.h"
#include "DockComponentsFactory.h"
#include "DockedEditorTitleBar.h"
#include "DockAreaTabBar.h"

#include "ScintillaNext.h"

Expand Down
182 changes: 128 additions & 54 deletions src/NotepadNext/EditorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "EditorManager.h"
#include "ScintillaNext.h"
#include "Scintilla.h"
#include "Settings.h"
#include "NotepadNextApplication.h"

// Editor decorators
#include "BraceMatch.h"
Expand All @@ -33,13 +35,12 @@
#include "AutoCompletion.h"
#include "URLFinder.h"
#include "BookMarkDecorator.h"

#include "ThemeColors.h"

const int MARK_HIDELINESBEGIN = 23;
const int MARK_HIDELINESEND = 22;
const int MARK_HIDELINESUNDERLINE = 21;


static int DefaultFontSize()
{
QFont font = QApplication::font();
Expand Down Expand Up @@ -110,11 +111,6 @@ void EditorManager::setupEditor(ScintillaNext *editor)
editor->clearCmdKey(SCK_INSERT);

editor->setFoldMarkers(QStringLiteral("box"));
for (int i = SC_MARKNUM_FOLDEREND; i <= SC_MARKNUM_FOLDEROPEN; ++i) {
editor->markerSetFore(i, 0xF3F3F3);
editor->markerSetBack(i, 0x808080);
editor->markerSetBackSelected(i, 0x0000FF);
}

editor->setIdleStyling(SC_IDLESTYLING_TOVISIBLE);
editor->setEndAtLastLine(false);
Expand All @@ -132,7 +128,7 @@ void EditorManager::setupEditor(ScintillaNext *editor)
editor->setMarginWidthN(2, 14);

editor->markerDefine(MARK_HIDELINESUNDERLINE, SC_MARK_UNDERLINE);
editor->markerSetBack(MARK_HIDELINESUNDERLINE, 0x77CC77);


editor->markerDefine(MARK_HIDELINESBEGIN, SC_MARK_ARROW);
editor->markerDefine(MARK_HIDELINESEND, SC_MARK_ARROWDOWN);
Expand All @@ -150,58 +146,21 @@ void EditorManager::setupEditor(ScintillaNext *editor)
editor->setCaretLineVisible(true);
editor->setCaretLineVisibleAlways(true);
editor->setCaretWidth(2);

editor->setEdgeColour(0x80FFFF);

// https://www.scintilla.org/ScintillaDoc.html#ElementColours
// SC_ELEMENT_SELECTION_TEXT
// SC_ELEMENT_SELECTION_BACK
// SC_ELEMENT_SELECTION_ADDITIONAL_TEXT
// SC_ELEMENT_SELECTION_ADDITIONAL_BACK
// SC_ELEMENT_SELECTION_SECONDARY_TEXT
// SC_ELEMENT_SELECTION_SECONDARY_BACK
// SC_ELEMENT_SELECTION_INACTIVE_TEXT
editor->setElementColour(SC_ELEMENT_SELECTION_INACTIVE_BACK, 0xFFE0E0E0);
// SC_ELEMENT_CARET
// SC_ELEMENT_CARET_ADDITIONAL
editor->setElementColour(SC_ELEMENT_CARET_LINE_BACK, 0xFFFFE8E8);
editor->setElementColour(SC_ELEMENT_WHITE_SPACE, 0xFFD0D0D0);
// SC_ELEMENT_WHITE_SPACE_BACK
// SC_ELEMENT_HOT_SPOT_ACTIVE
// SC_ELEMENT_HOT_SPOT_ACTIVE_BACK
editor->setElementColour(SC_ELEMENT_FOLD_LINE, 0xFFA0A0A0);
// SC_ELEMENT_HIDDEN_LINE

editor->setWhitespaceSize(2);

editor->setFoldMarginColour(true, 0xFFFFFF);
editor->setFoldMarginHiColour(true, 0xE9E9E9);


editor->setIndentationGuides(SC_IV_LOOKBOTH);

editor->setAutomaticFold(SC_AUTOMATICFOLD_SHOW | SC_AUTOMATICFOLD_CLICK | SC_AUTOMATICFOLD_CHANGE);
editor->markerEnableHighlight(true);


editor->styleSetFore(STYLE_DEFAULT, 0x000000);
editor->styleSetBack(STYLE_DEFAULT, 0xFFFFFF);
editor->markerEnableHighlight(true);

editor->setWhitespaceSize(2);

editor->styleSetSize(STYLE_DEFAULT, DefaultFontSize());
editor->styleSetFont(STYLE_DEFAULT, "Courier New");

editor->styleClearAll();

editor->styleSetFore(STYLE_LINENUMBER, 0x808080);
editor->styleSetBack(STYLE_LINENUMBER, 0xE4E4E4);
editor->styleSetFont(STYLE_DEFAULT, "Courier New");

editor->styleSetBold(STYLE_LINENUMBER, false);

editor->styleSetFore(STYLE_BRACELIGHT, 0x0000FF);
editor->styleSetBack(STYLE_BRACELIGHT, 0xFFFFFF);

editor->styleSetFore(STYLE_BRACEBAD, 0x000080);
editor->styleSetBack(STYLE_BRACEBAD, 0xFFFFFF);

editor->styleSetFore(STYLE_INDENTGUIDE, 0xC0C0C0);
editor->styleSetBack(STYLE_INDENTGUIDE, 0xFFFFFF);
// set up editor theme, only colour now, dark mode aware
setupEditorTheme(editor);

// STYLE_CONTROLCHAR
// STYLE_CALLTIP
Expand Down Expand Up @@ -239,6 +198,116 @@ void EditorManager::setupEditor(ScintillaNext *editor)
bm->setEnabled(true);
}

void EditorManager::setupEditorTheme(ScintillaNext *editor)
{
if (getSettings()->darkMode()) {
editor->setCaretFore(DARK_DEFAULT_FG);

//editor->setSelFore(true, 0xEFEFEF);
editor->setSelBack(true, 0xA0A0A0);

// folding/arker
for (int i = SC_MARKNUM_FOLDEREND; i <= SC_MARKNUM_FOLDEROPEN; ++i) {
editor->markerSetFore(i, 0x808080);
editor->markerSetBack(i, 0x1F1F1F);
editor->markerSetBackSelected(i, 0x0000FF);
}

editor->markerSetBack(MARK_HIDELINESUNDERLINE, invertColor(0x77CC77));
// end folding/marker

editor->setEdgeColour(invertColor(0x80FFFF));

// https://www.scintilla.org/ScintillaDoc.html#ElementColours
// SC_ELEMENT_SELECTION_TEXT
// SC_ELEMENT_SELECTION_BACK
// SC_ELEMENT_SELECTION_ADDITIONAL_TEXT
// SC_ELEMENT_SELECTION_ADDITIONAL_BACK
// SC_ELEMENT_SELECTION_SECONDARY_TEXT
// SC_ELEMENT_SELECTION_SECONDARY_BACK
// SC_ELEMENT_SELECTION_INACTIVE_TEXT
editor->setElementColour(SC_ELEMENT_SELECTION_INACTIVE_BACK, invertColor(0xFFE0E0E0));
// SC_ELEMENT_CARET
// SC_ELEMENT_CARET_ADDITIONAL
editor->setElementColour(SC_ELEMENT_CARET_LINE_BACK, 0x606060);
// SC_ELEMENT_WHITE_SPACE
// SC_ELEMENT_WHITE_SPACE_BACK
// setElementColour supports transparency!
editor->setElementColour(SC_ELEMENT_WHITE_SPACE, invertColor(0xFFD0D0D0));
editor->setElementColour(SC_ELEMENT_WHITE_SPACE_BACK, DARK_DEFAULT_BG);

// SC_ELEMENT_HOT_SPOT_ACTIVE
// SC_ELEMENT_HOT_SPOT_ACTIVE_BACK
editor->setElementColour(SC_ELEMENT_FOLD_LINE, invertColor(0xFFA0A0A0));
// SC_ELEMENT_HIDDEN_LINE

editor->setFoldMarginColour(true, 0x3F3F3F);
editor->setFoldMarginHiColour(true, 0xE9E9E9);

editor->styleSetFore(STYLE_DEFAULT, DARK_DEFAULT_FG);
editor->styleSetBack(STYLE_DEFAULT, DARK_DEFAULT_BG);

editor->styleSetFore(STYLE_LINENUMBER, 0xE4E4E4);
editor->styleSetBack(STYLE_LINENUMBER, 0x808080);

editor->styleSetFore(STYLE_BRACELIGHT, DARK_DEFAULT_FG);
editor->styleSetBack(STYLE_BRACELIGHT, 0x0000FF);

editor->styleSetFore(STYLE_BRACEBAD, DARK_DEFAULT_FG);
editor->styleSetBack(STYLE_BRACEBAD, 0x000080);

editor->styleSetFore(STYLE_INDENTGUIDE, 0xC0C0C0);
editor->styleSetBack(STYLE_INDENTGUIDE, DARK_DEFAULT_BG);
}
else {
for (int i = SC_MARKNUM_FOLDEREND; i <= SC_MARKNUM_FOLDEROPEN; ++i) {
editor->markerSetFore(i, 0xF3F3F3);
editor->markerSetBack(i, 0x808080);
editor->markerSetBackSelected(i, 0x0000FF);
}

editor->markerSetBack(MARK_HIDELINESUNDERLINE, 0x77CC77);
editor->setEdgeColour(0x80FFFF);

// https://www.scintilla.org/ScintillaDoc.html#ElementColours
// SC_ELEMENT_SELECTION_TEXT
// SC_ELEMENT_SELECTION_BACK
// SC_ELEMENT_SELECTION_ADDITIONAL_TEXT
// SC_ELEMENT_SELECTION_ADDITIONAL_BACK
// SC_ELEMENT_SELECTION_SECONDARY_TEXT
// SC_ELEMENT_SELECTION_SECONDARY_BACK
// SC_ELEMENT_SELECTION_INACTIVE_TEXT
editor->setElementColour(SC_ELEMENT_SELECTION_INACTIVE_BACK, 0xFFE0E0E0);
// SC_ELEMENT_CARET
// SC_ELEMENT_CARET_ADDITIONAL
editor->setElementColour(SC_ELEMENT_CARET_LINE_BACK, 0xFFFFE8E8);
editor->setElementColour(SC_ELEMENT_WHITE_SPACE, 0xFFD0D0D0);
// SC_ELEMENT_WHITE_SPACE_BACK
// SC_ELEMENT_HOT_SPOT_ACTIVE
// SC_ELEMENT_HOT_SPOT_ACTIVE_BACK
editor->setElementColour(SC_ELEMENT_FOLD_LINE, 0xFFA0A0A0);
// SC_ELEMENT_HIDDEN_LINE

editor->setFoldMarginColour(true, WHITE);
editor->setFoldMarginHiColour(true, 0xE9E9E9);

editor->styleSetFore(STYLE_DEFAULT, LIGHT_DEFAULT_FG);
editor->styleSetBack(STYLE_DEFAULT, LIGHT_DEFAULT_BG);

editor->styleSetFore(STYLE_LINENUMBER, 0x808080);
editor->styleSetBack(STYLE_LINENUMBER, 0xE4E4E4);

editor->styleSetFore(STYLE_BRACELIGHT, 0x0000FF);
editor->styleSetBack(STYLE_BRACELIGHT, LIGHT_DEFAULT_BG);

editor->styleSetFore(STYLE_BRACEBAD, 0x000080);
editor->styleSetBack(STYLE_BRACEBAD, LIGHT_DEFAULT_BG);

editor->styleSetFore(STYLE_INDENTGUIDE, 0xC0C0C0);
editor->styleSetBack(STYLE_INDENTGUIDE, LIGHT_DEFAULT_BG);
}
}

void EditorManager::purgeOldEditorPointers()
{
QMutableListIterator<QPointer<ScintillaNext>> it(editors);
Expand All @@ -249,3 +318,8 @@ void EditorManager::purgeOldEditorPointers()
it.remove();
}
}

Settings* EditorManager::getSettings()
{
return ((NotepadNextApplication*)parent())->getSettings();
}
4 changes: 3 additions & 1 deletion src/NotepadNext/EditorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <QObject>
#include <QPointer>


class ScintillaNext;
class Settings;

class EditorManager : public QObject
{
Expand All @@ -46,7 +46,9 @@ class EditorManager : public QObject

private:
void setupEditor(ScintillaNext *editor);
void setupEditorTheme(ScintillaNext *editor);
void purgeOldEditorPointers();
Settings* getSettings();

QList<QPointer<ScintillaNext>> editors;
};
Expand Down
8 changes: 7 additions & 1 deletion src/NotepadNext/LuaState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static int require_resource(lua_State *L)
{
const char *module = luaL_checkstring(L, 1);

QString module_file = QString(":/languages/%1.lua").arg(module);
QString module_file = QString(":/%1/%2.lua").arg(luaLanguagePath, module);
QFile f(module_file);

lua_pop(L, 1);
Expand Down Expand Up @@ -144,6 +144,11 @@ void LuaState::execute(const char *statement, bool clear)
lua_settop(L, stacktop);
}

void LuaState::execute(const QString &statement)
{
execute(statement.toLatin1().constData());
}

void LuaState::executeFile(const QString &fileName)
{
QFile ff(fileName);
Expand Down Expand Up @@ -174,3 +179,4 @@ void LuaState::raiseError(const char *errorMessage)
lua_concat(L, 2);
lua_error(L);
}

4 changes: 3 additions & 1 deletion src/NotepadNext/LuaState.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@

struct lua_State;

extern QString luaLanguagePath;

class LuaState
{
public:
LuaState();
~LuaState();

void execute(const char *statement, bool clear = true);
void execute(const QString& statement);
void executeFile(const QString &fileName);

template<typename T>
Expand All @@ -44,7 +47,6 @@ class LuaState
void raiseError(const char *errorMessage = Q_NULLPTR);

lua_State *L = Q_NULLPTR;

private:
};

Expand Down
3 changes: 2 additions & 1 deletion src/NotepadNext/NotepadNext.pro
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ FORMS += \

RESOURCES += \
resources.qrc \
scripts.qrc
scripts.qrc \
qdarkstyle/dark/style.qrc

INCLUDEPATH += $$PWD/decorators
INCLUDEPATH += $$PWD/dialogs
Expand Down
Loading