Merge pull request #751 from mwerle/feature/editor-show-whitespace

feat: add an option to render whitespace in the diff and editor views
This commit is contained in:
Murmele 2024-05-12 18:38:23 +02:00 committed by GitHub
commit 39ccb2661c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 3432 additions and 3177 deletions

2
.gitignore vendored
View File

@ -10,4 +10,4 @@ build
.idea/ .idea/
.venv .venv
compile_commands.json compile_commands.json
tags

View File

@ -14,6 +14,9 @@ return {
family = family, family = family,
size = size size = size
}, },
view = {
showWhitespace = false
},
indent = { indent = {
tabs = true, tabs = true,
width = 4, width = 4,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ void Setting::initialize(QMap<Id, QString> &keys) {
keys[Id::IndentWidth] = "editor/indent/width"; keys[Id::IndentWidth] = "editor/indent/width";
keys[Id::TabWidth] = "editor/indent/tabwidth"; keys[Id::TabWidth] = "editor/indent/tabwidth";
keys[Id::ShowHeatmapInBlameMargin] = "editor/blame/heatmap"; keys[Id::ShowHeatmapInBlameMargin] = "editor/blame/heatmap";
keys[Id::ShowWhitespaceInEditor] = "editor/view/showWhitespace";
keys[Id::ColorTheme] = "window/theme"; keys[Id::ColorTheme] = "window/theme";
keys[Id::ShowFullRepoPath] = "window/path/full"; keys[Id::ShowFullRepoPath] = "window/path/full";
keys[Id::HideLogAutomatically] = "window/log/hide"; keys[Id::HideLogAutomatically] = "window/log/hide";

View File

@ -36,6 +36,7 @@ public:
IndentWidth, IndentWidth,
TabWidth, TabWidth,
ShowHeatmapInBlameMargin, ShowHeatmapInBlameMargin,
ShowWhitespaceInEditor,
ColorTheme, ColorTheme,
ShowFullRepoPath, ShowFullRepoPath,
HideLogAutomatically, HideLogAutomatically,

View File

@ -661,6 +661,14 @@ public:
Settings::instance()->setValue(Setting::Id::FontSize, i); Settings::instance()->setValue(Setting::Id::FontSize, i);
}); });
QCheckBox *showWhitespace = new QCheckBox(tr("Show whitespace"), this);
showWhitespace->setChecked(
settings->value(Setting::Id::ShowWhitespaceInEditor).toBool());
connect(showWhitespace, &QCheckBox::toggled, [](bool checked) {
Settings::instance()->setValue(Setting::Id::ShowWhitespaceInEditor,
checked);
});
QComboBox *indent = new QComboBox(this); QComboBox *indent = new QComboBox(this);
indent->addItem(tr("Tabs")); indent->addItem(tr("Tabs"));
indent->addItem(tr("Spaces")); indent->addItem(tr("Spaces"));
@ -695,6 +703,7 @@ public:
QFormLayout *layout = new QFormLayout(this); QFormLayout *layout = new QFormLayout(this);
layout->addRow(tr("Font:"), font); layout->addRow(tr("Font:"), font);
layout->addRow(tr("Font size:"), fontSize); layout->addRow(tr("Font size:"), fontSize);
layout->addRow(tr("Whitespace:"), showWhitespace);
layout->addRow(tr("Indent using:"), indent); layout->addRow(tr("Indent using:"), indent);
layout->addRow(tr("Indent width:"), indentWidth); layout->addRow(tr("Indent width:"), indentWidth);
layout->addRow(tr("Tab width:"), tabWidth); layout->addRow(tr("Tab width:"), tabWidth);

View File

@ -182,6 +182,7 @@ void TextEditor::applySettings() {
setUseTabs(settings->value(Setting::Id::UseTabsForIndent).toBool()); setUseTabs(settings->value(Setting::Id::UseTabsForIndent).toBool());
setIndent(settings->value(Setting::Id::IndentWidth).toInt()); setIndent(settings->value(Setting::Id::IndentWidth).toInt());
setTabWidth(settings->value(Setting::Id::TabWidth).toInt()); setTabWidth(settings->value(Setting::Id::TabWidth).toInt());
setViewWS(settings->value(Setting::Id::ShowWhitespaceInEditor).toBool());
if (Settings::instance()->isTextEditorWrapLines()) { if (Settings::instance()->isTextEditorWrapLines()) {
setWrapMode(SC_WRAP_WORD); setWrapMode(SC_WRAP_WORD);