Skip to content
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
55 changes: 55 additions & 0 deletions src/bin/edit/draw_menubar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,58 @@ pub fn draw_dialog_about(ctx: &mut Context, state: &mut State) {
state.wants_about = false;
}
}

pub fn draw_dialog_shortcuts(ctx: &mut Context, state: &mut State) {
ctx.modal_begin("Shortcuts", loc(LocId::KeyboardShortcutDialogTitle));
{
ctx.block_begin("content");
ctx.inherit_focus();
ctx.attr_padding(Rect::three(1, 2, 1));
{
ctx.attr_position(Position::Center);

let shortcuts = [
(loc(LocId::EditCopy), "Ctrl + C"),
(loc(LocId::EditCut), "Ctrl + X"),
(loc(LocId::EditPaste), "Ctrl + V"),
(loc(LocId::EditUndo), "Ctrl + Z"),
(loc(LocId::EditRedo), "Ctrl + Y"),
(loc(LocId::EditFind), "Ctrl + F"),
(loc(LocId::EditReplace), "Ctrl + R"),
(loc(LocId::EditSelectAll), "Ctrl + A"),
(loc(LocId::FileNew), "Ctrl + N"),
(loc(LocId::FileOpen), "Ctrl + O"),
(loc(LocId::FileSave), "Ctrl + S"),
(loc(LocId::FileClose), "Ctrl + W"),
(loc(LocId::FileExit), "Ctrl + Q"),
(loc(LocId::FileGoto), "Ctrl + G"),
(loc(LocId::ShortcutSelectLine), "Ctrl + L"),
];

ctx.table_begin("shortcuts_table");
ctx.table_set_cell_gap(Size { width: (5), height: (0) });
for (desc, key) in shortcuts.iter() {
ctx.table_next_row();
ctx.label("shortcut_desc", desc);
ctx.label("shortcut_key", key);
}
ctx.table_end();

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_shortcuts_list = false;
}
ctx.inherit_focus();
}
ctx.block_end();
}
ctx.block_end();
}
if ctx.modal_end() {
state.wants_shortcuts_list = false;
}
}
5 changes: 3 additions & 2 deletions src/bin/edit/draw_statusbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn draw_statusbar(ctx: &mut Context, state: &mut State) {
let mut tb = doc.buffer.borrow_mut();

ctx.table_next_row();
ctx.label("help-hint", "[F1=Help]");

if ctx.button("newline", if tb.is_crlf() { "CRLF" } else { "LF" }, ButtonStyle::default()) {
let is_crlf = tb.is_crlf();
Expand Down Expand Up @@ -121,7 +122,7 @@ pub fn draw_statusbar(ctx: &mut Context, state: &mut State) {
}
}
ctx.list_end();

ctx.list_begin("width");
ctx.attr_padding(Rect::two(0, 2));
{
Expand Down Expand Up @@ -171,7 +172,7 @@ pub fn draw_statusbar(ctx: &mut Context, state: &mut State) {
if tb.is_dirty() {
ctx.label("dirty", "*");
}

ctx.block_begin("filename-container");
ctx.attr_intrinsic_size(Size { width: COORD_TYPE_SAFE_MAX, height: 1 });
{
Expand Down
31 changes: 31 additions & 0 deletions src/bin/edit/localization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ pub enum LocId {
FileOverwriteWarning,
FileOverwriteWarningDescription,

// Keyboard shortcuts dialog
KeyboardShortcutDialogTitle,
ShortcutSelectLine,
Count,
}

Expand Down Expand Up @@ -959,6 +962,34 @@ const S_LANG_LUT: [[&str; LangId::Count as usize]; LocId::Count as usize] = [
/* zh_hans */ "文件已存在。要覆盖它吗?",
/* zh_hant */ "檔案已存在。要覆蓋它嗎?",
],
//KeyboardShortcutsDialogTitle
[
/* en */ "Keyboard Shortcuts",
/* de */ "Tastenkürzel",
/* es */ "Atajos de teclado",
/* fr */ "Raccourcis clavier",
/* it */ "Scorciatoie da tastiera",
/* ja */ "キーボードショートカット",
/* ko */ "키보드 단축키",
/* pt_br */ "Atalhos de teclado",
/* ru */ "Сочетания клавиш",
/* zh_hans */ "键盘快捷键",
/* zh_hant */ "鍵盤快速鍵",
],
// ShortcutSelectLine
[
/* en */ "Select line",
/* de */ "Zeile auswählen",
/* es */ "Seleccionar línea",
/* fr */ "Sélectionner la ligne",
/* it */ "Seleziona riga",
/* ja */ "行を選択",
/* ko */ "줄 선택",
/* pt_br */ "Selecionar linha",
/* ru */ "Выделить строку",
/* zh_hans */ "选择行",
/* zh_hant */ "選取行",
],
];

static mut S_LANG: LangId = LangId::en;
Expand Down
8 changes: 7 additions & 1 deletion src/bin/edit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ fn draw(ctx: &mut Context, state: &mut State) {
if state.error_log_count != 0 {
draw_error_log(ctx, state);
}
if state.wants_shortcuts_list {
draw_dialog_shortcuts(ctx, state);
}

if let Some(key) = ctx.keyboard_input() {
// Shortcuts that are not handled as part of the textarea, etc.
Expand Down Expand Up @@ -347,7 +350,10 @@ fn draw(ctx: &mut Context, state: &mut State) {
state.wants_search.focus = true;
} else if key == vk::F3 {
search_execute(ctx, state, SearchAction::Search);
} else {
} else if key == vk:: F1 {
state.wants_shortcuts_list = true;
}
else {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions src/bin/edit/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ pub struct State {
pub wants_close: bool,
pub wants_exit: bool,
pub wants_goto: bool,
pub wants_shortcuts_list: bool,
pub goto_target: String,
pub goto_invalid: bool,

Expand Down Expand Up @@ -209,6 +210,7 @@ impl State {
wants_indentation_picker: false,
wants_go_to_file: false,
wants_about: false,
wants_shortcuts_list:false,
wants_close: false,
wants_exit: false,
wants_goto: false,
Expand Down