Some refactoring
This commit is contained in:
1 parent
1a8a96e1cd
commit
662ed9ca6c
2 files changed
+16
-21
No files matched your search
@@ -14,6 +14,7 @@ pub(crate) struct TextBuffer {
|
||||
pub(crate) cursor_pos: Cursor,
|
||||
pub(crate) buffer_settings: BufferSettings,
|
||||
pub(crate) backing_file: Option<PathBuf>,
|
||||
pub(crate) writeable: bool,
|
||||
}
|
||||
|
||||
//TODO consider try_ versions of rope methods to avoid panic
|
||||
@@ -24,6 +25,7 @@ impl TextBuffer {
|
||||
cursor_pos: Cursor::new(),
|
||||
buffer_settings: BufferSettings::new(),
|
||||
backing_file: None,
|
||||
writeable: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +40,7 @@ impl TextBuffer {
|
||||
cursor_pos: Cursor::new(),
|
||||
buffer_settings: BufferSettings::new(),
|
||||
backing_file: None,
|
||||
writeable: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-21
@@ -31,21 +31,12 @@ impl TerminalState {
|
||||
])
|
||||
.split(area);
|
||||
|
||||
let cursor_style = cursor_style(&app);
|
||||
let line_number_style = line_number_style(&app);
|
||||
|
||||
let active_buffer = app.active_buffer();
|
||||
let cursor = active_buffer.cursor_pos;
|
||||
|
||||
//frame.render_widget(Paragraph::new(text).white().on_black(), layout[0]);
|
||||
|
||||
self.render_buffer(
|
||||
frame,
|
||||
active_buffer,
|
||||
layout[0],
|
||||
line_number_style,
|
||||
cursor_style,
|
||||
);
|
||||
self.render_main_buffers(frame, layout[0], app);
|
||||
|
||||
frame.render_widget(
|
||||
Paragraph::new(vec![Line::from(vec![
|
||||
@@ -64,18 +55,15 @@ impl TerminalState {
|
||||
self.render_command(frame, app, layout[2]);
|
||||
}
|
||||
|
||||
fn render_buffer(
|
||||
&mut self,
|
||||
frame: &mut Frame,
|
||||
active_buffer: &TextBuffer,
|
||||
rect: Rect,
|
||||
line_number_style: Style,
|
||||
cursor_style: Style,
|
||||
) {
|
||||
let terminal_buf_height = rect.height;
|
||||
let cursor = &active_buffer.cursor_pos;
|
||||
fn render_main_buffers(&mut self, frame: &mut Frame, rect: Rect, core: &EditorCore) {
|
||||
let cursor_style = cursor_style(&core);
|
||||
let line_number_style = line_number_style(&core);
|
||||
|
||||
let active_buffer = core.active_buffer();
|
||||
|
||||
let expand_tab = active_buffer.buffer_settings.expand_tab;
|
||||
let terminal_buf_height = rect.height;
|
||||
let cursor = &active_buffer.cursor_pos;
|
||||
|
||||
// TODO do this more efficiently
|
||||
let start = 0 as usize;
|
||||
@@ -115,7 +103,11 @@ impl TerminalState {
|
||||
}
|
||||
}
|
||||
|
||||
frame.render_widget(Paragraph::new(text).white().on_black(), rect);
|
||||
render_single_buffer(frame, rect, text);
|
||||
|
||||
fn render_single_buffer(frame: &mut Frame, rect: Rect, text: Vec<Line>) {
|
||||
frame.render_widget(Paragraph::new(text).white().on_black(), rect);
|
||||
}
|
||||
}
|
||||
|
||||
fn render_command(&mut self, frame: &mut Frame, app: &EditorCore, rect: Rect) {
|
||||
|
||||
Reference in new issue
Block a user