PaneLayout type

This commit is contained in:
Greg Shuflin committed 2024-03-11 02:42:59 -07:00
1 parent 9dd04b0fa6
commit 310eb326a4
2 files changed
+32

No files matched your search

+8
View File
@@ -4,6 +4,7 @@ mod buffer_settings;
pub(crate) mod commands;
mod cursor;
mod error;
mod pane_layout;
use std::{
collections::HashMap,
@@ -26,6 +27,7 @@ use self::{
buffer::{BufferId, TextBuffer},
commands::{CommandOutput, Commands},
error::{log_only, BasicError},
pane_layout::PaneLayout,
};
#[derive(Clone, Debug)]
@@ -48,6 +50,7 @@ pub(crate) enum Mode {
pub(crate) struct EditorCore {
pub mirrored: bool,
buffers: HashMap<BufferId, TextBuffer>,
pane_layout: PaneLayout,
active_buffer: BufferId,
mode: Mode,
configuration: Configuration,
@@ -61,11 +64,16 @@ impl EditorCore {
let mut buffers = HashMap::new();
let active_buffer = BufferId(0);
buffers.insert(active_buffer, TextBuffer::new());
let mut pane_layout = PaneLayout::new();
pane_layout.add_new_buffer(active_buffer);
let (command_tx, command_output_rx) = tokio::sync::mpsc::unbounded_channel();
let core = Self {
mirrored: true,
buffers,
pane_layout,
active_buffer,
configuration: Configuration::new(),
mode: Mode::Normal,
+24
View File
@@ -0,0 +1,24 @@
use std::collections::HashMap;
use super::buffer::BufferId;
pub(super) struct PaneLayout {
map: HashMap<BufferId, PaneDescriptor>,
}
impl PaneLayout {
pub(super) fn new() -> Self {
Self {
map: HashMap::new(),
}
}
pub(super) fn add_new_buffer(&mut self, id: BufferId) {
self.map.insert(id, PaneDescriptor::Main { tab: 0 });
}
}
pub(crate) enum PaneDescriptor {
Main { tab: u16 },
Floating,
}