mirror of
https://github.com/microsoft/edit.git
synced 2025-08-04 10:59:57 +00:00
Do not render View menu when no documents are active (#447)
Closes #430 Co-authored-by: Leonard Hecker <leonard@hecker.io>
This commit is contained in:
parent
4b2fe697e8
commit
2e56fa6ef1
3 changed files with 16 additions and 10 deletions
|
@ -22,11 +22,13 @@ pub fn draw_menubar(ctx: &mut Context, state: &mut State) {
|
||||||
if !contains_focus && ctx.consume_shortcut(vk::F10) {
|
if !contains_focus && ctx.consume_shortcut(vk::F10) {
|
||||||
ctx.steal_focus();
|
ctx.steal_focus();
|
||||||
}
|
}
|
||||||
if state.documents.active().is_some() && ctx.menubar_menu_begin(loc(LocId::Edit), 'E') {
|
if state.documents.active().is_some() {
|
||||||
draw_menu_edit(ctx, state);
|
if ctx.menubar_menu_begin(loc(LocId::Edit), 'E') {
|
||||||
}
|
draw_menu_edit(ctx, state);
|
||||||
if ctx.menubar_menu_begin(loc(LocId::View), 'V') {
|
}
|
||||||
draw_menu_view(ctx, state);
|
if ctx.menubar_menu_begin(loc(LocId::View), 'V') {
|
||||||
|
draw_menu_view(ctx, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ctx.menubar_menu_begin(loc(LocId::Help), 'H') {
|
if ctx.menubar_menu_begin(loc(LocId::Help), 'H') {
|
||||||
draw_menu_help(ctx, state);
|
draw_menu_help(ctx, state);
|
||||||
|
@ -99,14 +101,14 @@ fn draw_menu_edit(ctx: &mut Context, state: &mut State) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_menu_view(ctx: &mut Context, state: &mut State) {
|
fn draw_menu_view(ctx: &mut Context, state: &mut State) {
|
||||||
if ctx.menubar_menu_button(loc(LocId::ViewFocusStatusbar), 'S', vk::NULL) {
|
|
||||||
state.wants_statusbar_focus = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(doc) = state.documents.active() {
|
if let Some(doc) = state.documents.active() {
|
||||||
let mut tb = doc.buffer.borrow_mut();
|
let mut tb = doc.buffer.borrow_mut();
|
||||||
let word_wrap = tb.is_word_wrap_enabled();
|
let word_wrap = tb.is_word_wrap_enabled();
|
||||||
|
|
||||||
|
// All values on the statusbar are currently document specific.
|
||||||
|
if ctx.menubar_menu_button(loc(LocId::ViewFocusStatusbar), 'S', vk::NULL) {
|
||||||
|
state.wants_statusbar_focus = true;
|
||||||
|
}
|
||||||
if ctx.menubar_menu_button(loc(LocId::ViewDocumentPicker), 'P', kbmod::CTRL | vk::P) {
|
if ctx.menubar_menu_button(loc(LocId::ViewDocumentPicker), 'P', kbmod::CTRL | vk::P) {
|
||||||
state.wants_document_picker = true;
|
state.wants_document_picker = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,10 @@ pub fn draw_statusbar(ctx: &mut Context, state: &mut State) {
|
||||||
ctx.attr_position(Position::Right);
|
ctx.attr_position(Position::Right);
|
||||||
}
|
}
|
||||||
ctx.block_end();
|
ctx.block_end();
|
||||||
|
} else {
|
||||||
|
state.wants_statusbar_focus = false;
|
||||||
|
state.wants_encoding_picker = false;
|
||||||
|
state.wants_indentation_picker = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.table_end();
|
ctx.table_end();
|
||||||
|
|
|
@ -145,12 +145,12 @@ pub struct State {
|
||||||
pub search_success: bool,
|
pub search_success: bool,
|
||||||
|
|
||||||
pub wants_encoding_picker: bool,
|
pub wants_encoding_picker: bool,
|
||||||
|
pub wants_encoding_change: StateEncodingChange,
|
||||||
pub encoding_picker_needle: String,
|
pub encoding_picker_needle: String,
|
||||||
pub encoding_picker_results: Option<Vec<icu::Encoding>>,
|
pub encoding_picker_results: Option<Vec<icu::Encoding>>,
|
||||||
|
|
||||||
pub wants_save: bool,
|
pub wants_save: bool,
|
||||||
pub wants_statusbar_focus: bool,
|
pub wants_statusbar_focus: bool,
|
||||||
pub wants_encoding_change: StateEncodingChange,
|
|
||||||
pub wants_indentation_picker: bool,
|
pub wants_indentation_picker: bool,
|
||||||
pub wants_document_picker: bool,
|
pub wants_document_picker: bool,
|
||||||
pub wants_about: bool,
|
pub wants_about: bool,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue