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

Auto indent feature add #562

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add option to auto-indent text (#561, Allen Benter).


# 2.21 (2020-12-07)
* Update MathJax to version 3 (#515, @dgcampea).
Expand Down
1 change: 1 addition & 0 deletions rednotebook/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Config(dict):
"leftDividerPosition": 260,
"rightDividerPosition": None,
"cloudMaxTags": 1000,
"autoindent": 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use "autoIndent" here and auto_indent in the rest of the code, please?

jendrikseipp marked this conversation as resolved.
Show resolved Hide resolved
}

obsolete_keys = {
Expand Down
8 changes: 8 additions & 0 deletions rednotebook/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's shorten this a bit:

def set_auto_indent(self):
    auto_indent = self.journal.config.read("autoindent") == 1
    self.day_text_field.day_text_view.set_auto_indent(auto_indent)


def set_font(self, font_name):
self.day_text_field.set_font(font_name)
Expand Down
3 changes: 3 additions & 0 deletions rednotebook/gui/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down