From 680adc5882c90d660e3344cd80f5cfe310a816a8 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 3 Feb 2024 13:25:01 -0600 Subject: [PATCH] refactoring --- src/edit.rs | 7 +++++-- src/interactive.rs | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/edit.rs b/src/edit.rs index 0486b1f..27e22d7 100644 --- a/src/edit.rs +++ b/src/edit.rs @@ -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, @@ -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(); diff --git a/src/interactive.rs b/src/interactive.rs index 4d7965a..b2a39ac 100644 --- a/src/interactive.rs +++ b/src/interactive.rs @@ -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(), }) }