[tui] Add EditorTab widget.
+ This adds support for tabbed editors wrapped by EditorTab widgets. + The Explorer widget now opens new EditorTabs when a file is selected with Enter. + The same file may not be opened multiple times. + Tabs can be switched with ALT+h or ALT+l (or ALT+ arrow keys) + Tabs cannot yet be closed :) Fixes #9
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use crate::tui::component::Action::Pass;
|
||||
use crate::tui::component::{Action, Component, ComponentState};
|
||||
use crate::tui::menu_bar::MenuBarItemOption::{
|
||||
About, Exit, Reload, Save, ShowHideExplorer, ShowHideLogger,
|
||||
@@ -33,12 +32,12 @@ enum MenuBarItemOption {
|
||||
impl MenuBarItemOption {
|
||||
fn id(&self) -> &str {
|
||||
match self {
|
||||
MenuBarItemOption::Save => "Save",
|
||||
MenuBarItemOption::Reload => "Reload",
|
||||
MenuBarItemOption::Exit => "Exit",
|
||||
MenuBarItemOption::ShowHideExplorer => "Show / hide explorer",
|
||||
MenuBarItemOption::ShowHideLogger => "Show / hide logger",
|
||||
MenuBarItemOption::About => "About",
|
||||
Save => "Save",
|
||||
Reload => "Reload",
|
||||
Exit => "Exit",
|
||||
ShowHideExplorer => "Show / hide explorer",
|
||||
ShowHideLogger => "Show / hide logger",
|
||||
About => "About",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,7 +115,7 @@ impl MenuBar {
|
||||
buf: &mut Buffer,
|
||||
opened: MenuBarItem,
|
||||
) {
|
||||
let popup_area = Self::rect_under_option(title_bar_anchor, area, 40, 10);
|
||||
let popup_area = Self::rect_under_option(title_bar_anchor, area, 27, 10);
|
||||
Clear::default().render(popup_area, buf);
|
||||
let options = opened.options().iter().map(|i| ListItem::new(i.id()));
|
||||
StatefulWidget::render(
|
||||
|
||||
Reference in New Issue
Block a user