Skip to content
Snippets Groups Projects
Commit 88366081 authored by Ticki's avatar Ticki
Browse files

Major refactoring in Sodium

parent c076c3b8
No related branches found
No related tags found
No related merge requests found
use super::*; use editor::Editor;
use mode::{Mode, CommandMode, PrimitiveMode};
#[derive(Clone)] #[derive(Clone)]
/// A cursor, i.e. a state defining a mode, and a position. The cursor does not define the content /// A cursor, i.e. a state defining a mode, and a position. The cursor does not define the content
......
use super::*; use editor::Editor;
use redraw::RedrawTask;
impl Editor { impl Editor {
/// Delete a character /// Delete a character
......
use super::*; use cursor::Cursor;
use orbital::*; use std::collections::VecDeque;
use orbital::Window;
use graphics::StatusBar;
use options::Options;
use key_state::KeyState;
use redraw::RedrawTask;
/// The current state of the editor, including the file, the cursor, the scrolling info, etc. /// The current state of the editor, including the file, the cursor, the scrolling info, etc.
pub struct Editor { pub struct Editor {
......
use super::*; use editor::Editor;
use parse::{Inst, Parameter};
use key::Key;
use mode::{Mode, CommandMode, PrimitiveMode};
use insert::{InsertOptions, InsertMode};
use redraw::RedrawTask;
use std::collections::VecDeque;
use std::iter::FromIterator; use std::iter::FromIterator;
// TODO: Move the command definitions outta here // TODO: Move the command definitions outta here
impl Editor { impl Editor {
/// Execute an instruction /// Execute an instruction
pub fn exec(&mut self, Inst(para, cmd): Inst) { pub fn exec(&mut self, Inst(para, cmd): Inst) {
use super::Key::*; use key::Key::*;
use super::Mode::*; use mode::Mode::*;
use super::PrimitiveMode::*; use mode::PrimitiveMode::*;
use super::CommandMode::*; use mode::CommandMode::*;
let n = para.d(); let n = para.d();
let bef = self.pos(); let bef = self.pos();
......
use super::*; use editor::Editor;
use orbital::*; use orbital::Color;
use redraw::RedrawTask;
use mode::Mode;
use mode::PrimitiveMode;
use mode::CommandMode;
impl Editor { impl Editor {
/// Redraw the window /// Redraw the window
......
use super::*; use editor::Editor;
use mode::{Mode, PrimitiveMode, CommandMode};
use redraw::RedrawTask;
use key::Key;
use std::collections::VecDeque;
use std::iter::FromIterator; use std::iter::FromIterator;
#[derive(Clone, PartialEq, Copy)] #[derive(Clone, PartialEq, Copy)]
......
use super::*; use editor::Editor;
impl Editor { impl Editor {
pub fn invert_chars(&mut self, n: usize) { pub fn invert_chars(&mut self, n: usize) {
...@@ -7,7 +7,7 @@ impl Editor { ...@@ -7,7 +7,7 @@ impl Editor {
let current = self.current(); let current = self.current();
if let Some(c) = self.text[y].get_mut(x) { if let Some(c) = self.text[y].get_mut(x) {
if let Some(cur) = current { if let Some(cur) = current {
*c = invert::invert(cur); *c = invert(cur);
} }
} }
if let Some(m) = self.next(1) { if let Some(m) = self.next(1) {
......
use super::*; use key::Key;
use orbital::*; use orbital::{
KeyEvent,
K_ALT,
K_CTRL,
K_LEFT_SHIFT,
K_RIGHT_SHIFT
};
/// Key state /// Key state
pub struct KeyState { pub struct KeyState {
......
extern crate orbital; extern crate orbital;
pub use std::collections::VecDeque; pub mod editor;
pub mod parse;
mod editor; pub mod key_state;
pub use self::editor::*; pub mod key;
pub mod prompt;
mod parse; pub mod open;
pub use self::parse::*; pub mod redraw;
pub mod options;
mod key_state; pub mod position;
pub use self::key_state::*; pub mod graphics;
pub mod selection;
mod key; pub mod mode;
pub use self::key::*; pub mod movement;
pub mod motion;
mod prompt; pub mod cursor;
pub use self::prompt::*; pub mod insert;
pub mod delete;
mod open; pub mod exec;
pub use self::open::*;
mod redraw;
pub use self::redraw::*;
mod options;
pub use self::options::*;
mod position;
pub use self::position::*;
mod graphics;
pub use self::graphics::*;
mod selection;
pub use self::selection::*;
mod mode;
pub use self::mode::*;
mod movement;
pub use self::movement::*;
mod motion;
pub use self::motion::*;
mod cursor;
pub use self::cursor::*;
mod insert;
pub use self::insert::*;
mod delete;
pub use self::delete::*;
mod exec;
pub use self::exec::*;
pub mod invert; pub mod invert;
#[no_mangle] pub fn main() { #[no_mangle]
Editor::init(); pub fn main() {
editor::Editor::init();
} }
use super::*; use insert::InsertOptions;
use editor::Editor;
#[derive(Clone, PartialEq, Copy)] #[derive(Clone, PartialEq, Copy)]
/// A mode. Modes determine which set of commands that will be used. Modes comes in two flavors: /// A mode. Modes determine which set of commands that will be used. Modes comes in two flavors:
......
use super::*; use editor::Editor;
use parse::Inst;
use position::to_signed_pos;
impl Editor { impl Editor {
/// Convert an instruction to a motion (new coordinate). Returns None if the instructions given /// Convert an instruction to a motion (new coordinate). Returns None if the instructions given
...@@ -9,7 +11,7 @@ impl Editor { ...@@ -9,7 +11,7 @@ impl Editor {
/// d deletes the text given by the motion following. Other commands can make use of motions, /// d deletes the text given by the motion following. Other commands can make use of motions,
/// using this method. /// using this method.
pub fn to_motion(&mut self, Inst(n, cmd): Inst) -> Option<(usize, usize)> { pub fn to_motion(&mut self, Inst(n, cmd): Inst) -> Option<(usize, usize)> {
use super::Key::*; use key::Key::*;
match cmd.key { match cmd.key {
Char('h') => Some(self.left(n.d())), Char('h') => Some(self.left(n.d())),
Char('l') => Some(self.right(n.d())), Char('l') => Some(self.right(n.d())),
...@@ -54,7 +56,7 @@ impl Editor { ...@@ -54,7 +56,7 @@ impl Editor {
/// cases it's a position which is out of bounds. This is useful when commands want to mesure /// cases it's a position which is out of bounds. This is useful when commands want to mesure
/// the relative movement over the movement. /// the relative movement over the movement.
pub fn to_motion_unbounded(&mut self, Inst(n, cmd): Inst) -> Option<(isize, isize)> { pub fn to_motion_unbounded(&mut self, Inst(n, cmd): Inst) -> Option<(isize, isize)> {
use super::Key::*; use key::Key::*;
match cmd.key { match cmd.key {
Char('h') => Some(self.left_unbounded(n.d())), Char('h') => Some(self.left_unbounded(n.d())),
Char('l') => Some(self.right_unbounded(n.d())), Char('l') => Some(self.right_unbounded(n.d())),
......
use super::*; use editor::Editor;
impl Editor { impl Editor {
/// Goto a given position. Does not automatically bound. /// Goto a given position. Does not automatically bound.
......
use super::*; use editor::Editor;
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::Read;
use std::collections::VecDeque;
pub enum OpenStatus { pub enum OpenStatus {
Ok, Ok,
......
use super::*; use key::{Cmd, Key};
use orbital::*; use editor::Editor;
use orbital::{EventOption, Event};
use redraw::RedrawTask;
use mode::Mode;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
/// An instruction, i.e. a command and a numeral parameter /// An instruction, i.e. a command and a numeral parameter
......
use super::*; use editor::Editor;
/// Convert a usize tuple to isize /// Convert a usize tuple to isize
pub fn to_signed_pos((x, y): (usize, usize)) -> (isize, isize) { pub fn to_signed_pos((x, y): (usize, usize)) -> (isize, isize) {
......
use super::*; use editor::Editor;
use open::OpenStatus;
impl Editor { impl Editor {
/// Invoke a command in the prompt /// Invoke a command in the prompt
......
use std::ops::Range; use std::ops::Range;
#[derive(Clone)] #[derive(Clone)]
/// A task for the renderer for redrawing
pub enum RedrawTask { pub enum RedrawTask {
Null, Null,
Lines(Range<usize>), Lines(Range<usize>),
......
use super::*; use editor::Editor;
use std::collections::VecDeque;
impl Editor { impl Editor {
/// Remove from a given motion (row based), i.e. if the motion given is to another line, all /// Remove from a given motion (row based), i.e. if the motion given is to another line, all
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment