Commit 3c193021 authored by Ticki's avatar Ticki

merge

parents 1a23c608 d483f3e3
......@@ -7,6 +7,7 @@ Sodium: A modern vi-like editor
"""
[dependencies]
orbclient = "0.1"
[features]
orbital = []
......
......@@ -8,7 +8,7 @@ use buffer::{Buffer, SplitBuffer};
use parse::Inst;
#[cfg(feature = "orbital")]
use orbital::Window;
use orbclient::Window;
/// The current state of the editor, including the file, the cursor, the scrolling info, etc.
pub struct Editor<B> {
......
......@@ -6,7 +6,7 @@ use mode::CommandMode;
use buffer::{Buffer, Line};
#[cfg(feature = "orbital")]
use orbital::Color;
use orbclient::Color;
#[cfg(feature = "ansi")]
mod terminal {
......@@ -162,9 +162,10 @@ impl<'a, B: Buffer<'a>> Editor<B> {
pub fn redraw<'b: 'a>(&'b mut self) {
// I was here -- bug
let (mut pos_x, pos_y) = self.pos();
{ // TODO Unnecessary?
// TODO: Only draw when relevant for the window
let (mut pos_x, pos_y) = self.pos();
// Redraw window
self.window.set(Color::rgb(25, 25, 25));
......@@ -191,20 +192,20 @@ impl<'a, B: Buffer<'a>> Editor<B> {
16,
Color::rgb(255, 255, 255));
let mut string = false;
let mut string = false;
for (y, row) in self.buffer.lines().enumerate() {
for (x, c) in row.chars().enumerate() {
// TODO: Move outta here
let color = if self.options.highlight {
match c {
'\'' | '"' => {
string = !string;
(226, 225, 167) //(167, 222, 156)
},
_ if string => (226, 225, 167), //(167, 222, 156)
'!' |
for (y, row) in self.buffer.lines().enumerate() {
for (x, c) in row.chars().enumerate() {
// TODO: Move outta here
let color = if self.options.highlight {
match c {
'\'' | '"' => {
string = !string;
(226, 225, 167) //(167, 222, 156)
},
_ if string => (226, 225, 167), //(167, 222, 156)
'!' |
'@' |
'#' |
'$' |
......@@ -220,32 +221,31 @@ impl<'a, B: Buffer<'a>> Editor<B> {
'=' |
'<' |
'>' => (198, 83, 83), //(228, 190, 175), //(194, 106, 71),
'.' | ',' => (241, 213, 226),
'(' | ')' | '[' | ']' | '{' | '}' => (164, 212, 125), //(195, 139, 75),
'0' ... '9' => (209, 209, 177),
_ => (255, 255, 255),
}
} else {
(255, 255, 255)
};
let c = if c == '\t' {
' '
} else {
c
};
if pos_x == x && pos_y == y {
self.window.char(8 * (x - self.scroll_x) as i32,
16 * (y - self.scroll_y) as i32,
c,
Color::rgb(color.0 / 3, color.1 / 3, color.2 / 3));
} else {
self.window.char(8 * (x - self.scroll_x) as i32,
16 * (y - self.scroll_y) as i32,
c,
Color::rgb(color.0, color.1, color.2));
'.' | ',' => (241, 213, 226),
'(' | ')' | '[' | ']' | '{' | '}' => (164, 212, 125), //(195, 139, 75),
'0' ... '9' => (209, 209, 177),
_ => (255, 255, 255),
}
} else {
(255, 255, 255)
};
let c = if c == '\t' {
' '
} else {
c
};
if pos_x == x && pos_y == y {
self.window.char(8 * (x - self.scroll_x) as i32,
16 * (y - self.scroll_y) as i32,
c,
Color::rgb(color.0 / 3, color.1 / 3, color.2 / 3));
} else {
self.window.char(8 * (x - self.scroll_x) as i32,
16 * (y - self.scroll_y) as i32,
c,
Color::rgb(color.0, color.1, color.2));
}
}
}
......@@ -285,7 +285,7 @@ impl<'a, B: Buffer<'a>> Editor<B> {
status_bar(self, sb_msg, 3, 4);
for (n, c) in self.prompt.chars().enumerate() {
self.window.char(n as i32 * 8, h as i32 - 16 - 1, c, Color::WHITE);
self.window.char(n as i32 * 8, h as i32 - 16 - 1, c, Color::rgb(255, 255, 255));
}
self.window.sync();
......@@ -318,7 +318,7 @@ fn status_bar<'a, B: Buffer<'a>>(editor: &mut Editor<B>, text: String, a: u32, b
}
},
c,
Color::WHITE);
Color::rgb(255, 255, 255));
}
}
......
#[cfg(feature = "orbital")]
use orbital::{
use orbclient::{
KeyEvent,
K_BKSP,
K_LEFT,
......
use key::Key;
#[cfg(feature = "orbital")]
use orbital::KeyEvent;
use orbclient::KeyEvent;
#[cfg(feature = "ansi")]
use std::io::Stdin;
......@@ -26,7 +26,7 @@ impl KeyState {
/// Feed the keystate
#[cfg(feature = "orbital")]
pub fn feed(&mut self, k: KeyEvent) -> Option<Key> {
use orbital::{
use orbclient::{
K_ALT,
K_CTRL,
K_LEFT_SHIFT,
......
......@@ -3,9 +3,7 @@
#![feature(type_ascription)]
#[cfg(feature = "orbital")]
extern crate orbital;
extern crate collections;
extern crate orbclient;
extern crate collections;
......
......@@ -5,7 +5,7 @@ use mode::Mode;
use buffer::Buffer;
#[cfg(feature = "orbital")]
use orbital::{EventOption, Event};
use orbclient::{EventOption, Event};
#[derive(Copy, Clone)]
/// An instruction, i.e. a command and a numeral parameter
......@@ -44,7 +44,7 @@ impl<'a, B: Buffer<'a>> Editor<B> {
#[cfg(feature = "orbital")]
loop {
match self.window
.poll()
.events().next()
.unwrap_or(Event::new())
.to_option() {
EventOption::Key(k) => {
......@@ -71,7 +71,7 @@ impl<'a, B: Buffer<'a>> Editor<B> {
// self.status_bar.cmd = String::new();
#[cfg(feature = "orbital")]
loop {
match self.window.poll()
match self.window.events().next()
.unwrap_or(Event::new())
.to_option() {
EventOption::Key(key_event) => {
......
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