Starting point for special char processing
This commit is contained in:
parent
4eb025ba91
commit
c339a27481
@ -27,6 +27,11 @@ impl Level {
|
||||
//TODO: double width chars render, also note in text wrapping
|
||||
//TODO: im
|
||||
|
||||
pub fn insert(&mut self, c: &str, shift: bool, render_state: &shell::RenderState) {
|
||||
self.model_layout.insert(c, shift);
|
||||
self.update_preferred_size(render_state);
|
||||
}
|
||||
|
||||
pub fn replace_from_ctx(&mut self, ctx: &CmdLineContext, render_state: &shell::RenderState) {
|
||||
let content = ctx.get_lines();
|
||||
self.replace_line(&content.lines, false);
|
||||
@ -79,9 +84,7 @@ impl Level {
|
||||
.map(|line_chars| {
|
||||
line_chars
|
||||
.iter()
|
||||
.map(|c| {
|
||||
(Some(Attrs::from_value_map(&c.0)), c.1.chars().collect())
|
||||
})
|
||||
.map(|c| (Some(Attrs::from_value_map(&c.0)), c.1.chars().collect()))
|
||||
.collect()
|
||||
})
|
||||
.collect()
|
||||
@ -254,7 +257,6 @@ impl State {
|
||||
}
|
||||
|
||||
impl cursor::CursorRedrawCb for State {
|
||||
|
||||
fn queue_redraw_cursor(&mut self) {
|
||||
self.queue_redraw_cursor();
|
||||
}
|
||||
@ -323,6 +325,26 @@ impl CmdLine {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn special_char(
|
||||
&self,
|
||||
render_state: &shell::RenderState,
|
||||
c: String,
|
||||
shift: bool,
|
||||
level: u64,
|
||||
) {
|
||||
let mut state = self.state.borrow_mut();
|
||||
|
||||
if let Some(level) = state.levels.get_mut((level - 1) as usize) {
|
||||
level.insert(&c, shift, render_state);
|
||||
level.update_cache(&*render_state);
|
||||
} else {
|
||||
error!("Level {} does not exists", level);
|
||||
}
|
||||
|
||||
state.request_area_size();
|
||||
state.drawing_area.queue_draw()
|
||||
}
|
||||
|
||||
pub fn hide_level(&mut self, level_idx: u64) {
|
||||
let mut state = self.state.borrow_mut();
|
||||
|
||||
@ -350,16 +372,13 @@ impl CmdLine {
|
||||
state.request_area_size();
|
||||
}
|
||||
|
||||
|
||||
pub fn block_append(&mut self, content: &Vec<(HashMap<String, Value>, String)>) {
|
||||
let mut state = self.state.borrow_mut();
|
||||
let render_state = state.render_state.clone();
|
||||
{
|
||||
let attr_content = content
|
||||
.iter()
|
||||
.map(|c| {
|
||||
(Some(Attrs::from_value_map(&c.0)), c.1.chars().collect())
|
||||
})
|
||||
.map(|c| (Some(Attrs::from_value_map(&c.0)), c.1.chars().collect()))
|
||||
.collect();
|
||||
|
||||
let block = state.block.as_mut().unwrap();
|
||||
@ -441,9 +460,7 @@ impl CmdLineContext {
|
||||
fn get_lines(&self) -> LineContent {
|
||||
let content_line: Vec<(Option<Attrs>, Vec<char>)> = self.content
|
||||
.iter()
|
||||
.map(|c| {
|
||||
(Some(Attrs::from_value_map(&c.0)), c.1.chars().collect())
|
||||
})
|
||||
.map(|c| (Some(Attrs::from_value_map(&c.0)), c.1.chars().collect()))
|
||||
.collect();
|
||||
let (prompt_offset, prompt_lines) = prompt_lines(&self.firstc, &self.prompt, self.indent);
|
||||
|
||||
|
@ -95,6 +95,8 @@ pub trait RedrawEvents {
|
||||
fn cmdline_block_hide(&mut self) -> RepaintMode;
|
||||
|
||||
fn cmdline_pos(&mut self, pos: u64, level: u64) -> RepaintMode;
|
||||
|
||||
fn cmdline_special_char(&mut self, c: String, shift: bool, level: u64) -> RepaintMode;
|
||||
}
|
||||
|
||||
pub trait GuiApi {
|
||||
@ -323,6 +325,7 @@ pub fn call(
|
||||
"cmdline_hide" => call!(ui->cmdline_hide(args: uint)),
|
||||
"cmdline_block_hide" => ui.cmdline_block_hide(),
|
||||
"cmdline_pos" => call!(ui->cmdline_pos(args: uint, uint)),
|
||||
"cmdline_special_char" => call!(ui->cmdline_special_char(args: str, bool, uint)),
|
||||
_ => {
|
||||
warn!("Event {}({:?})", method, args);
|
||||
RepaintMode::Nothing
|
||||
|
@ -1197,6 +1197,12 @@ impl RedrawEvents for State {
|
||||
self.cmd_line.pos(&*render_state, pos, level);
|
||||
RepaintMode::Nothing
|
||||
}
|
||||
|
||||
fn cmdline_special_char(&mut self, c: String, shift: bool, level: u64) -> RepaintMode {
|
||||
let render_state = self.render_state.borrow();
|
||||
self.cmd_line.special_char(&*render_state, c, shift, level);
|
||||
RepaintMode::Nothing
|
||||
}
|
||||
}
|
||||
|
||||
impl CursorRedrawCb for State {
|
||||
|
@ -58,6 +58,18 @@ impl ModelLayout {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, c: &str, shift: bool) {
|
||||
if c.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if shift {
|
||||
//TODO: insert special char
|
||||
} else {
|
||||
self.model.put(c.chars().next().unwrap(), false, None);
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrap all lines into model
|
||||
///
|
||||
/// returns actual width
|
||||
|
Loading…
Reference in New Issue
Block a user