refactoring

main
Jordan Orelli 9 months ago
parent f39a22d408
commit 680adc5882

@ -1,7 +1,9 @@
use crate::log::*;
use std::cmp::min;
pub struct Editor {
/// An interactive text editor. The Editor is in control of all line editing functionality. It is a
/// type of text editor, albeit an extremely primitive one.
pub struct Buffer {
/// the current contents of the line
chars: Vec<char>,
@ -9,7 +11,7 @@ pub struct Editor {
cursor: usize,
}
impl Editor {
impl Buffer {
pub fn new() -> Self {
Self {
chars: Vec::new(),
@ -17,6 +19,7 @@ impl Editor {
}
}
/// clears our edit buffer
pub fn clear(&mut self) {
self.cursor = 0;
self.chars.clear();

@ -1,5 +1,5 @@
use crate::{
edit::Editor,
edit,
ext::{Command, Echo, Printenv, Tail, Which},
input,
log::*,
@ -8,7 +8,6 @@ use crate::{
use std::{
error::Error,
fmt,
io::{self, Write},
path::{Path, PathBuf},
};
@ -16,10 +15,12 @@ use std::{
use anyhow::Result;
use dirs;
/// An interactive session. The Session object is the top-level object used to control an
/// interactive terminal session.
pub struct Session {
pub input: input::Reader,
pub output: output::Writer,
pub editor: Editor,
pub editor: edit::Buffer,
pub state: syntax::State,
}
@ -28,7 +29,7 @@ impl Session {
Ok(Self {
input: input::Reader::new()?,
output: output::Writer::stdout()?,
editor: Editor::new(),
editor: edit::Buffer::new(),
state: syntax::State::new(),
})
}

Loading…
Cancel
Save