diff --git a/src/bin/edit/draw_menubar.rs b/src/bin/edit/draw_menubar.rs index 07b7c713d056..bbdc98b2e0d2 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,51 @@ 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) { + let button_style = ButtonStyle::default().bracketed(true); + let doc = state.documents.active().unwrap(); + let mut tb = doc.buffer.borrow_mut(); + let 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, 1, 1)); + { + 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.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)); + 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..69462a1bfa68 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,11 @@ pub enum LocId { AboutDialogTitle, AboutDialogVersion, + // Settings dialog + SettingsDialogTitle, + SettingsDialogDescription1, + SettingsDialogDescription2, + // Shown when the clipboard size exceeds the limit for OSC 52 LargeClipboardWarningLine1, LargeClipboardWarningLine2, @@ -542,6 +548,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 +663,49 @@ 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 */ "設定", + ], + // SettingsDialogDescription1 + [ + /* 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 */ "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 // 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,