Commit f6f4c18d authored by Wesley Wiser's avatar Wesley Wiser

Rename Buffer -> TextBuffer and BufferInfo -> Buffer

parent d5e77d23
use caret::position::to_signed_pos;
use edit::buffer::Buffer;
use edit::buffer::TextBuffer;
use io::parse::Inst;
use state::editor::Editor;
......
use edit::buffer::Buffer;
use edit::buffer::TextBuffer;
use state::editor::Editor;
impl Editor {
......
use edit::buffer::Buffer;
use edit::buffer::TextBuffer;
use state::editor::Editor;
/// Convert a usize tuple to isize
......
......@@ -3,7 +3,7 @@ use io::parse::{Inst, Parameter};
use state::mode::{Mode, CommandMode, PrimitiveMode};
use edit::insert::{InsertOptions, InsertMode};
use io::redraw::RedrawTask;
use edit::buffer::Buffer;
use edit::buffer::TextBuffer;
// TODO: Move the command definitions outta here
impl Editor {
......
use io::file::FileStatus;
use io::redraw::RedrawTask;
use state::editor::{BufferInfo, BufferManager, Editor};
use edit::buffer::{Buffer, SplitBuffer};
use state::editor::{Buffer, BufferManager, Editor};
use edit::buffer::{TextBuffer, SplitBuffer};
use std::process::exit;
......@@ -54,7 +54,7 @@ impl Editor {
},
"ls" => {
let description = get_buffers_description(&self.buffers);
let mut new_buffer: BufferInfo = SplitBuffer::from_str(&description).into();
let mut new_buffer: Buffer = SplitBuffer::from_str(&description).into();
new_buffer.title = Some("<Buffers>".into());
new_buffer.is_transient = true; // delete the buffer when the user switches away
......@@ -94,7 +94,7 @@ impl Editor {
}
fn get_buffers_description(buffers: &BufferManager) -> String {
fn print_buffer(i: usize, b: &BufferInfo) -> String {
fn print_buffer(i: usize, b: &Buffer) -> String {
let title = b.title.as_ref().map(|s| s.as_str()).unwrap_or("<No Title>");
format!("b{}\t\t\t{}", i, title)
......
......@@ -20,7 +20,7 @@ impl<'a, T: AsRef<str>> Line<'a> for T {
}
/// A buffer structure
pub trait Buffer<'a> {
pub trait TextBuffer<'a> {
/// The line type of the buffer.
type Line: 'a + Line<'a>;
/// The line iterator.
......@@ -101,7 +101,7 @@ impl SplitBuffer {
}
}
impl<'a> Buffer<'a> for SplitBuffer {
impl<'a> TextBuffer<'a> for SplitBuffer {
type Line = String;
type LineIter = SplitBufIter<'a>;
......
use edit::buffer::Buffer;
use edit::buffer::TextBuffer;
use state::cursor::Cursor;
use state::editor::Editor;
use io::redraw::RedrawTask;
......
use edit::buffer::Buffer;
use edit::buffer::TextBuffer;
use io::key::Key;
use io::redraw::RedrawTask;
use state::editor::Editor;
......
use edit::buffer::Buffer;
use edit::buffer::TextBuffer;
use state::editor::Editor;
impl Editor {
......
use edit::buffer::{Buffer, SplitBuffer};
use state::editor::{BufferInfo, Editor};
use edit::buffer::{TextBuffer, SplitBuffer};
use state::editor::{Buffer, Editor};
use std::fs::File;
use std::io::{Read, Write};
......@@ -20,7 +20,7 @@ impl Editor {
let mut con = String::new();
let _ = file.read_to_string(&mut con);
let mut new_buffer : BufferInfo = SplitBuffer::from_str(&con).into();
let mut new_buffer: Buffer = SplitBuffer::from_str(&con).into();
new_buffer.title = Some(path.into());
let new_buffer_index = self.buffers.new_buffer(new_buffer);
......
use edit::buffer::Buffer;
use edit::buffer::TextBuffer;
use io::redraw::RedrawTask;
use state::editor::Editor;
use state::mode::{Mode, PrimitiveMode};
......
use std::slice::Iter;
use edit::buffer::{Buffer, SplitBuffer};
use edit::buffer::{TextBuffer, SplitBuffer};
use state::cursor::Cursor;
use io::graphics::StatusBar;
use io::key::{Key, Cmd};
......@@ -14,7 +14,7 @@ use orbclient::Window;
use std::env::args;
/// A SplitBuffer and related state
pub struct BufferInfo {
pub struct Buffer {
/// The document
pub raw_buffer: SplitBuffer,
/// The current cursor
......@@ -32,10 +32,10 @@ pub struct BufferInfo {
pub is_transient: bool,
}
impl BufferInfo {
/// Create a new BufferInfo with default values.
fn new() -> BufferInfo {
BufferInfo {
impl Buffer {
/// Create a new Buffer with default values.
fn new() -> Buffer {
Buffer {
raw_buffer: SplitBuffer::new(),
current_cursor: 0,
cursors: vec![Cursor::new()],
......@@ -47,9 +47,9 @@ impl BufferInfo {
}
}
impl From<SplitBuffer> for BufferInfo {
fn from(b: SplitBuffer) -> BufferInfo {
let mut info = BufferInfo::new();
impl From<SplitBuffer> for Buffer {
fn from(b: SplitBuffer) -> Buffer {
let mut info = Buffer::new();
info.raw_buffer = b;
info
......@@ -58,7 +58,7 @@ impl From<SplitBuffer> for BufferInfo {
/// Provides access to buffer manipulation functions.
pub struct BufferManager {
buffers: Vec<BufferInfo>,
buffers: Vec<Buffer>,
current_buffer_index: usize,
}
......@@ -66,21 +66,21 @@ impl BufferManager {
/// Create a new BufferManager with default values.
pub fn new() -> BufferManager {
BufferManager {
buffers: vec![BufferInfo::new()],
buffers: vec![Buffer::new()],
current_buffer_index: 0,
}
}
/// Adds the specified buffer to the set of buffers and returns
/// its index.
pub fn new_buffer(&mut self, buffer: BufferInfo) -> usize {
pub fn new_buffer(&mut self, buffer: Buffer) -> usize {
self.buffers.push(buffer);
self.buffers.len() - 1
}
/// Returns an iterator over the buffers.
pub fn iter(&self) -> Iter<BufferInfo> {
pub fn iter(&self) -> Iter<Buffer> {
self.buffers.iter()
}
......@@ -100,12 +100,12 @@ impl BufferManager {
}
/// Get a reference to the currently open buffer information.
pub fn current_buffer_info(&self) -> &BufferInfo {
pub fn current_buffer_info(&self) -> &Buffer {
&self.buffers[self.current_buffer_index]
}
/// Get a mutable reference to the currently open buffer information.
pub fn current_buffer_info_mut(&mut self) -> &mut BufferInfo {
pub fn current_buffer_info_mut(&mut self) -> &mut Buffer {
&mut self.buffers[self.current_buffer_index]
}
......@@ -136,7 +136,7 @@ impl BufferManager {
self.buffers.remove(n);
if self.buffers.len() == 0 {
self.buffers.push(BufferInfo::new());
self.buffers.push(Buffer::new());
self.current_buffer_index = 0;
} else if self.current_buffer_index <= n {
self.current_buffer_index -= 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment