Proof of concept - mirrored buffer
This commit is contained in:
1 parent
66a4c75734
commit
90301aa069
2 files changed
+32
-8
No files matched your search
@@ -46,6 +46,7 @@ pub(crate) enum Mode {
|
||||
}
|
||||
|
||||
pub(crate) struct EditorCore {
|
||||
pub mirrored: bool,
|
||||
buffers: HashMap<BufferId, TextBuffer>,
|
||||
active_buffer: BufferId,
|
||||
mode: Mode,
|
||||
@@ -63,6 +64,7 @@ impl EditorCore {
|
||||
let (command_tx, command_output_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
|
||||
let core = Self {
|
||||
mirrored: true,
|
||||
buffers,
|
||||
active_buffer,
|
||||
configuration: Configuration::new(),
|
||||
|
||||
+30
-8
@@ -62,15 +62,37 @@ impl TerminalState {
|
||||
let active_buffer = core.active_buffer();
|
||||
let terminal_buf_height = rect.height;
|
||||
|
||||
let text = render_single_buffer(
|
||||
active_buffer,
|
||||
terminal_buf_height,
|
||||
cursor_style,
|
||||
line_number_style,
|
||||
);
|
||||
frame.render_widget(Paragraph::new(text).white().on_black(), rect);
|
||||
if core.mirrored {
|
||||
let buffer_layout =
|
||||
Layout::horizontal([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)]).split(rect);
|
||||
|
||||
fn render_single_buffer<'a>(
|
||||
let text = single_buffer_lines(
|
||||
active_buffer,
|
||||
terminal_buf_height,
|
||||
cursor_style,
|
||||
line_number_style,
|
||||
);
|
||||
|
||||
frame.render_widget(Paragraph::new(text).white().on_black(), buffer_layout[0]);
|
||||
|
||||
let text = single_buffer_lines(
|
||||
active_buffer,
|
||||
terminal_buf_height,
|
||||
cursor_style,
|
||||
line_number_style,
|
||||
);
|
||||
frame.render_widget(Paragraph::new(text).white().on_black(), buffer_layout[1]);
|
||||
} else {
|
||||
let text = single_buffer_lines(
|
||||
active_buffer,
|
||||
terminal_buf_height,
|
||||
cursor_style,
|
||||
line_number_style,
|
||||
);
|
||||
frame.render_widget(Paragraph::new(text).white().on_black(), rect);
|
||||
}
|
||||
|
||||
fn single_buffer_lines<'a>(
|
||||
active_buffer: &TextBuffer,
|
||||
terminal_buf_height: u16,
|
||||
cursor_style: Style,
|
||||
|
||||
Reference in new issue
Block a user