diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f7edabfe..4b69fbdd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased * Add a "Give Feedback" button (#551, Rahul Jha). * Test code on macOS (#552, Rahul Jha). +* added feature to auto-indent text in editor (#561, Allen Benter) # 2.21 (2020-12-07) * Update MathJax to version 3 (#515, @dgcampea). diff --git a/rednotebook/configuration.py b/rednotebook/configuration.py index 15f63c1d7..22d83ef50 100644 --- a/rednotebook/configuration.py +++ b/rednotebook/configuration.py @@ -53,6 +53,7 @@ class Config(dict): "leftDividerPosition": 260, "rightDividerPosition": None, "cloudMaxTags": 1000, + "autoindent": 1, } obsolete_keys = { diff --git a/rednotebook/gui/main_window.py b/rednotebook/gui/main_window.py index 38396d720..1ecec1b50 100644 --- a/rednotebook/gui/main_window.py +++ b/rednotebook/gui/main_window.py @@ -666,6 +666,14 @@ def load_values_from_config(self): ) self.set_font(config.read("mainFont", editor.DEFAULT_FONT)) + + self.set_autoIndent() + + def set_autoIndent(self): + if self.journal.config.read("autoindent") == 1: + self.day_text_field.day_text_view.set_auto_indent(True) + else: + self.day_text_field.day_text_view.set_auto_indent(False) def set_font(self, font_name): self.day_text_field.set_font(font_name) diff --git a/rednotebook/gui/options.py b/rednotebook/gui/options.py index 48f94245b..3efc6e72a 100644 --- a/rednotebook/gui/options.py +++ b/rednotebook/gui/options.py @@ -320,6 +320,8 @@ def on_options_dialog(self): ) self.options.append(TickOption(_("Search as you type"), "instantSearch")) + + self.options.append(TickOption(_("Auto indent"), "autoindent")) def check_version_action(widget): utils.check_new_version( @@ -383,6 +385,7 @@ def check_version_action(widget): # Apply some options self.main_window.cloud.update_lists() self.main_window.cloud.update(force_update=True) + self.main_window.set_autoIndent() visible = self.config.read("closeToTray") == 1 self.main_window.tray_icon.set_visible(visible)