From ef78a6628177865327f0c741a5e9c6449f926ac2 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Thu, 20 Jun 2024 20:27:14 +0200 Subject: [PATCH] Add option to make Shift+Enter add \n instead of \N \n is useful in combination with a WrapStyle of 2, which plays nicer with style overrides. --- src/libresrc/default_config.json | 1 + src/libresrc/osx/default_config.json | 1 + src/preferences.cpp | 2 +- src/subs_edit_ctrl.cpp | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libresrc/default_config.json b/src/libresrc/default_config.json index 9b57e810f2..9d2a76f7e3 100644 --- a/src/libresrc/default_config.json +++ b/src/libresrc/default_config.json @@ -380,6 +380,7 @@ "Width" : 1280 }, "Edit Box" : { + "Soft Line Break": false, "Font Face" : "", "Font Size" : 10 }, diff --git a/src/libresrc/osx/default_config.json b/src/libresrc/osx/default_config.json index 07df9ce426..c3c91352c4 100644 --- a/src/libresrc/osx/default_config.json +++ b/src/libresrc/osx/default_config.json @@ -380,6 +380,7 @@ "Width" : 1280 }, "Edit Box" : { + "Soft Line Break": false, "Font Face" : "", "Font Size" : 13 }, diff --git a/src/preferences.cpp b/src/preferences.cpp index e176ac58ee..ab5f491fd8 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -207,7 +207,7 @@ void Interface(wxTreebook *book, Preferences *parent) { auto edit_box = p->PageSizer(_("Edit Box")); p->OptionAdd(edit_box, _("Enable call tips"), "App/Call Tips"); p->OptionAdd(edit_box, _("Overwrite in time boxes"), "Subtitle/Time Edit/Insert Mode"); - p->CellSkip(edit_box); + p->OptionAdd(edit_box, _("Shift+Enter adds \\n"), "Subtitle/Edit Box/Soft Line Break"); p->OptionAdd(edit_box, _("Enable syntax highlighting"), "Subtitle/Highlight/Syntax"); p->OptionBrowse(edit_box, _("Dictionaries path"), "Path/Dictionary"); p->OptionFont(edit_box, "Subtitle/Edit Box/"); diff --git a/src/subs_edit_ctrl.cpp b/src/subs_edit_ctrl.cpp index dbacce3911..9436332144 100644 --- a/src/subs_edit_ctrl.cpp +++ b/src/subs_edit_ctrl.cpp @@ -201,7 +201,7 @@ void SubsTextEditCtrl::OnKeyDown(wxKeyEvent &event) { auto sel_start = GetSelectionStart(), sel_end = GetSelectionEnd(); wxCharBuffer old = GetTextRaw(); std::string data(old.data(), sel_start); - data.append("\\N"); + data.append(OPT_GET("Subtitle/Edit Box/Soft Line Break")->GetBool() ? "\\n" : "\\N"); data.append(old.data() + sel_end, old.length() - sel_end); SetTextRaw(data.c_str());