From da7463c0fab953ebaafe0dd6e21e94bdf3eb6861 Mon Sep 17 00:00:00 2001 From: Skryta Istota <48822204+hidden-being@users.noreply.github.com> Date: Thu, 5 Jun 2025 17:45:56 +0200 Subject: [PATCH 1/4] Added global editor settings dialog --- src/bin/edit/draw_menubar.rs | 33 +++++++++++++++++++++++++ src/bin/edit/localization.rs | 48 ++++++++++++++++++++++++++++++++++++ src/bin/edit/main.rs | 3 +++ src/bin/edit/state.rs | 2 ++ 4 files changed, 86 insertions(+) diff --git a/src/bin/edit/draw_menubar.rs b/src/bin/edit/draw_menubar.rs index 07b7c713d056..f0e74e4cf773 100644 --- a/src/bin/edit/draw_menubar.rs +++ b/src/bin/edit/draw_menubar.rs @@ -123,6 +123,9 @@ fn draw_menu_view(ctx: &mut Context, state: &mut State) { } fn draw_menu_help(ctx: &mut Context, state: &mut State) { + if ctx.menubar_menu_button(loc(LocId::HelpSettings), 'S', vk::NULL) { + state.wants_settings = true; + } if ctx.menubar_menu_button(loc(LocId::HelpAbout), 'A', vk::NULL) { state.wants_about = true; } @@ -174,3 +177,33 @@ pub fn draw_dialog_about(ctx: &mut Context, state: &mut State) { state.wants_about = false; } } + +pub fn draw_dialog_settings(ctx: &mut Context, state: &mut State) { + ctx.modal_begin("settings", loc(LocId::SettingsDialogTitle)); + { + ctx.block_begin("content"); + ctx.inherit_focus(); + ctx.attr_padding(Rect::three(1, 2, 1)); + { + ctx.label("description", loc(LocId::SettingsDialogDescription)); + ctx.attr_overflow(Overflow::TruncateTail); + ctx.attr_position(Position::Center); + + ctx.block_begin("choices"); + ctx.inherit_focus(); + ctx.attr_padding(Rect::three(1, 2, 0)); + ctx.attr_position(Position::Center); + { + if ctx.button("ok", loc(LocId::Ok), ButtonStyle::default()) { + state.wants_settings = false; + } + ctx.inherit_focus(); + } + ctx.block_end(); + } + ctx.block_end(); + } + if ctx.modal_end() { + state.wants_settings = false; + } +} diff --git a/src/bin/edit/localization.rs b/src/bin/edit/localization.rs index 0443781363b3..1505d3ea8b0a 100644 --- a/src/bin/edit/localization.rs +++ b/src/bin/edit/localization.rs @@ -46,6 +46,7 @@ pub enum LocId { // Help menu Help, + HelpSettings, HelpAbout, // Exit dialog @@ -58,6 +59,10 @@ pub enum LocId { AboutDialogTitle, AboutDialogVersion, + // Settings dialog + SettingsDialogTitle, + SettingsDialogDescription, + // Shown when the clipboard size exceeds the limit for OSC 52 LargeClipboardWarningLine1, LargeClipboardWarningLine2, @@ -542,6 +547,20 @@ const S_LANG_LUT: [[&str; LangId::Count as usize]; LocId::Count as usize] = [ /* zh_hans */ "帮助", /* zh_hant */ "幫助", ], + // HelpSettings + [ + /* en */ "Settings…", + /* de */ "Einstellungen…", + /* es */ "Configuración…", + /* fr */ "Paramètres…", + /* it */ "Impostazioni…", + /* ja */ "設定…", + /* ko */ "설정…", + /* pt_br */ "Configurações…", + /* ru */ "Настройки…", + /* zh_hans */ "设置…", + /* zh_hant */ "設定…", + ], // HelpAbout [ /* en */ "About", @@ -643,6 +662,35 @@ const S_LANG_LUT: [[&str; LangId::Count as usize]; LocId::Count as usize] = [ /* zh_hant */ "版本: ", ], + // SettingsDialogTitle + [ + /* en */ "Settings", + /* de */ "Einstellungen", + /* es */ "Configuración", + /* fr */ "Paramètres", + /* it */ "Impostazioni", + /* ja */ "設定", + /* ko */ "설정", + /* pt_br */ "Configurações", + /* ru */ "Настройки", + /* zh_hans */ "设置", + /* zh_hant */ "設定", + ], + // SettingsDialogDescription + [ + /* en */ "Configure Microsoft Edit settings.", + /* de */ "Konfigurieren Sie die Einstellungen von Microsoft Edit.", + /* es */ "Configura la configuración de Microsoft Edit.", + /* fr */ "Configurez les paramètres de Microsoft Edit.", + /* it */ "Configura le impostazioni di Microsoft Edit.", + /* ja */ "Microsoft Edit の設定を行います。", + /* ko */ "Microsoft Edit 설정을 구성합니다.", + /* pt_br */ "Configure as configurações do Microsoft Edit.", + /* ru */ "Настройте параметры Microsoft Edit.", + /* zh_hans */ "配置 Microsoft Edit 设置。", + /* zh_hant */ "設定 Microsoft Edit 的選項。", + ], + // Shown when the clipboard size exceeds the limit for OSC 52 // LargeClipboardWarningLine1 [ diff --git a/src/bin/edit/main.rs b/src/bin/edit/main.rs index 71bf1e6a67fc..949c7c1c9aae 100644 --- a/src/bin/edit/main.rs +++ b/src/bin/edit/main.rs @@ -314,6 +314,9 @@ fn draw(ctx: &mut Context, state: &mut State) { if state.wants_document_picker { draw_document_picker(ctx, state); } + if state.wants_settings { + draw_dialog_settings(ctx, state); + } if state.wants_about { draw_dialog_about(ctx, state); } diff --git a/src/bin/edit/state.rs b/src/bin/edit/state.rs index 90689e59a6d5..fdda51acfa02 100644 --- a/src/bin/edit/state.rs +++ b/src/bin/edit/state.rs @@ -150,6 +150,7 @@ pub struct State { pub wants_encoding_change: StateEncodingChange, pub wants_indentation_picker: bool, pub wants_document_picker: bool, + pub wants_settings: bool, pub wants_about: bool, pub wants_close: bool, pub wants_exit: bool, @@ -195,6 +196,7 @@ impl State { wants_encoding_change: StateEncodingChange::None, wants_indentation_picker: false, wants_document_picker: false, + wants_settings: false, wants_about: false, wants_close: false, wants_exit: false, From ecce3a259c0de015af624e0cc0eca0e30c2a5ed2 Mon Sep 17 00:00:00 2001 From: Skryta Istota <48822204+hidden-being@users.noreply.github.com> Date: Thu, 5 Jun 2025 18:30:31 +0200 Subject: [PATCH 2/4] Line wrapping configurations can now be set via the global settings dialog --- src/bin/edit/draw_menubar.rs | 20 ++++++++++++++++++-- src/bin/edit/localization.rs | 19 +++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/bin/edit/draw_menubar.rs b/src/bin/edit/draw_menubar.rs index f0e74e4cf773..4620d2f8517d 100644 --- a/src/bin/edit/draw_menubar.rs +++ b/src/bin/edit/draw_menubar.rs @@ -179,13 +179,29 @@ pub fn draw_dialog_about(ctx: &mut Context, state: &mut State) { } pub fn draw_dialog_settings(ctx: &mut Context, state: &mut State) { + let doc = state.documents.active().unwrap(); + let mut tb = doc.buffer.borrow_mut(); + let mut word_wrap = tb.is_word_wrap_enabled(); + ctx.modal_begin("settings", loc(LocId::SettingsDialogTitle)); { ctx.block_begin("content"); ctx.inherit_focus(); - ctx.attr_padding(Rect::three(1, 2, 1)); + ctx.attr_padding(Rect::three(1, 1, 1)); { - ctx.label("description", loc(LocId::SettingsDialogDescription)); + ctx.label("description1", loc(LocId::SettingsDialogDescription1)); + ctx.attr_overflow(Overflow::TruncateTail); + ctx.attr_position(Position::Center); + + ctx.label("description2", loc(LocId::SettingsDialogDescription2)); + ctx.attr_background_rgba(0xFF00FFFF); + ctx.attr_overflow(Overflow::TruncateTail); + ctx.attr_position(Position::Center); + + if ctx.checkbox("word-wrap", loc(LocId::ViewWordWrap), &mut word_wrap) { + tb.set_word_wrap(word_wrap); + ctx.needs_rerender(); + } ctx.attr_overflow(Overflow::TruncateTail); ctx.attr_position(Position::Center); diff --git a/src/bin/edit/localization.rs b/src/bin/edit/localization.rs index 1505d3ea8b0a..e11b2cebf173 100644 --- a/src/bin/edit/localization.rs +++ b/src/bin/edit/localization.rs @@ -61,7 +61,8 @@ pub enum LocId { // Settings dialog SettingsDialogTitle, - SettingsDialogDescription, + SettingsDialogDescription1, + SettingsDialogDescription2, // Shown when the clipboard size exceeds the limit for OSC 52 LargeClipboardWarningLine1, @@ -676,7 +677,7 @@ const S_LANG_LUT: [[&str; LangId::Count as usize]; LocId::Count as usize] = [ /* zh_hans */ "设置", /* zh_hant */ "設定", ], - // SettingsDialogDescription + // SettingsDialogDescription1 [ /* en */ "Configure Microsoft Edit settings.", /* de */ "Konfigurieren Sie die Einstellungen von Microsoft Edit.", @@ -690,6 +691,20 @@ const S_LANG_LUT: [[&str; LangId::Count as usize]; LocId::Count as usize] = [ /* zh_hans */ "配置 Microsoft Edit 设置。", /* zh_hant */ "設定 Microsoft Edit 的選項。", ], + // SettingsDialogDescription2 + [ + /* en */ "You can also configure settings per file in the editor.", + /* de */ "Sie können auch Einstellungen pro Datei im Editor konfigurieren.", + /* es */ "También puedes configurar la configuración por archivo en el editor.", + /* fr */ "Vous pouvez également configurer les paramètres par fichier dans l’éditeur.", + /* it */ "Puoi anche configurare le impostazioni per file nell'editor.", + /* ja */ "エディターでファイルごとに設定を行うこともできます。", + /* ko */ "편집기에서 파일별로 설정을 구성할 수 있습니다.", + /* pt_br */ "Você também pode configurar as configurações por arquivo no editor.", + /* ru */ "Вы также можете настроить параметры для файла в редакторе.", + /* zh_hans */ "您还可以在编辑器中为每个文件配置设置。", + /* zh_hant */ "您也可以在編輯器中為每個檔案設定選項。", + ], // Shown when the clipboard size exceeds the limit for OSC 52 // LargeClipboardWarningLine1 From 8df0479905e57f93736c907b6f53e0ad7b6ec727 Mon Sep 17 00:00:00 2001 From: Skryta Istota <48822204+hidden-being@users.noreply.github.com> Date: Thu, 5 Jun 2025 18:55:56 +0200 Subject: [PATCH 3/4] Improved machine translations for the settings dialog --- src/bin/edit/draw_menubar.rs | 1 + src/bin/edit/localization.rs | 44 ++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/bin/edit/draw_menubar.rs b/src/bin/edit/draw_menubar.rs index 4620d2f8517d..934c713f3aa4 100644 --- a/src/bin/edit/draw_menubar.rs +++ b/src/bin/edit/draw_menubar.rs @@ -202,6 +202,7 @@ pub fn draw_dialog_settings(ctx: &mut Context, state: &mut State) { tb.set_word_wrap(word_wrap); ctx.needs_rerender(); } + ctx.attr_padding(Rect::three(1, 0, 0)); ctx.attr_overflow(Overflow::TruncateTail); ctx.attr_position(Position::Center); diff --git a/src/bin/edit/localization.rs b/src/bin/edit/localization.rs index e11b2cebf173..69462a1bfa68 100644 --- a/src/bin/edit/localization.rs +++ b/src/bin/edit/localization.rs @@ -679,31 +679,31 @@ const S_LANG_LUT: [[&str; LangId::Count as usize]; LocId::Count as usize] = [ ], // SettingsDialogDescription1 [ - /* en */ "Configure Microsoft Edit settings.", - /* de */ "Konfigurieren Sie die Einstellungen von Microsoft Edit.", - /* es */ "Configura la configuración de Microsoft Edit.", - /* fr */ "Configurez les paramètres de Microsoft Edit.", - /* it */ "Configura le impostazioni di Microsoft Edit.", - /* ja */ "Microsoft Edit の設定を行います。", - /* ko */ "Microsoft Edit 설정을 구성합니다.", - /* pt_br */ "Configure as configurações do Microsoft Edit.", - /* ru */ "Настройте параметры Microsoft Edit.", - /* zh_hans */ "配置 Microsoft Edit 设置。", - /* zh_hant */ "設定 Microsoft Edit 的選項。", + /* en */ "Global configuration of Microsoft Edit.", + /* de */ "Globale Konfiguration des Programms Microsoft Edit.", + /* es */ "Configuración global del programa Microsoft Edit.", + /* fr */ "Configuration globale du programme Microsoft Edit.", + /* it */ "Configurazione globale del programma Microsoft Edit.", + /* ja */ "Microsoft Edit のグローバル設定。", + /* ko */ "Microsoft Edit 프로그램의 글로벌 설정.", + /* pt_br */ "Configuração global do programa Microsoft Edit.", + /* ru */ "Глобальная конфигурация программы Microsoft Edit.", + /* zh_hans */ "Microsoft Edit 程序的全球配置。", + /* zh_hant */ "Microsoft Edit 的全球配置。", ], // SettingsDialogDescription2 [ - /* en */ "You can also configure settings per file in the editor.", - /* de */ "Sie können auch Einstellungen pro Datei im Editor konfigurieren.", - /* es */ "También puedes configurar la configuración por archivo en el editor.", - /* fr */ "Vous pouvez également configurer les paramètres par fichier dans l’éditeur.", - /* it */ "Puoi anche configurare le impostazioni per file nell'editor.", - /* ja */ "エディターでファイルごとに設定を行うこともできます。", - /* ko */ "편집기에서 파일별로 설정을 구성할 수 있습니다.", - /* pt_br */ "Você também pode configurar as configurações por arquivo no editor.", - /* ru */ "Вы также можете настроить параметры для файла в редакторе.", - /* zh_hans */ "您还可以在编辑器中为每个文件配置设置。", - /* zh_hant */ "您也可以在編輯器中為每個檔案設定選項。", + /* en */ "This editor is not yet able to remember user settings.", + /* de */ "Dieser Editor kann die Benutzereinstellungen noch nicht speichern.", + /* es */ "Este editor aún no es capaz de recordar la configuración del usuario.", + /* fr */ "Cet éditeur n'est pas encore capable de mémoriser les paramètres utilisateur.", + /* it */ "Questo editor non è ancora in grado di memorizzare le impostazioni dell'utente.", + /* ja */ "このエディターは、まだユーザーの設定を記憶する機能を備えていません。", + /* ko */ "이 편집기는 아직 사용자의 설정을 저장할 수 없습니다.", + /* pt_br */ "Este editor ainda não é capaz de memorizar as configurações do usuário.", + /* ru */ "Этот редактор еще не может запоминать настройки пользователя.", + /* zh_hans */ "该编辑器目前尚不支持保存用户设置。", + /* zh_hant */ "该编辑器尚无法记住用户设置。", ], // Shown when the clipboard size exceeds the limit for OSC 52 From a4a3ca6f962fd683b7b49b2d8e6aff6a34897bec Mon Sep 17 00:00:00 2001 From: Skryta Istota <48822204+hidden-being@users.noreply.github.com> Date: Thu, 5 Jun 2025 19:25:26 +0200 Subject: [PATCH 4/4] Changed functions for rendering buttons in the settings dialog --- src/bin/edit/draw_menubar.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bin/edit/draw_menubar.rs b/src/bin/edit/draw_menubar.rs index 934c713f3aa4..bbdc98b2e0d2 100644 --- a/src/bin/edit/draw_menubar.rs +++ b/src/bin/edit/draw_menubar.rs @@ -179,9 +179,10 @@ pub fn draw_dialog_about(ctx: &mut Context, state: &mut State) { } pub fn draw_dialog_settings(ctx: &mut Context, state: &mut State) { + let button_style = ButtonStyle::default().bracketed(true); let doc = state.documents.active().unwrap(); let mut tb = doc.buffer.borrow_mut(); - let mut word_wrap = tb.is_word_wrap_enabled(); + let word_wrap = tb.is_word_wrap_enabled(); ctx.modal_begin("settings", loc(LocId::SettingsDialogTitle)); { @@ -198,8 +199,8 @@ pub fn draw_dialog_settings(ctx: &mut Context, state: &mut State) { ctx.attr_overflow(Overflow::TruncateTail); ctx.attr_position(Position::Center); - if ctx.checkbox("word-wrap", loc(LocId::ViewWordWrap), &mut word_wrap) { - tb.set_word_wrap(word_wrap); + if ctx.button("word-wrap", loc(LocId::ViewWordWrap), button_style.accelerator('W')) { + tb.set_word_wrap(!word_wrap); ctx.needs_rerender(); } ctx.attr_padding(Rect::three(1, 0, 0));