Skip to content

Commit

Permalink
Move redraw event handlers into their own functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vhakulinen committed Jul 3, 2020
1 parent d6e8fda commit 7492a38
Show file tree
Hide file tree
Showing 6 changed files with 392 additions and 355 deletions.
10 changes: 5 additions & 5 deletions src/ui/cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl CmdlineBlock {

fn append(
&mut self,
append: &nvim_bridge::CmdlineBlockAppend,
append: nvim_bridge::CmdlineBlockAppend,
hl_defs: &HlDefs,
) {
let buffer = self.textview.get_buffer().unwrap();
Expand Down Expand Up @@ -271,7 +271,7 @@ impl CmdlineInput {

fn set_text(
&mut self,
content: &nvim_bridge::CmdlineShow,
content: nvim_bridge::CmdlineShow,
hl_defs: &HlDefs,
) {
let buffer = self.textview.get_buffer().unwrap();
Expand Down Expand Up @@ -305,7 +305,7 @@ impl CmdlineInput {
}

self.current_level = content.level;
self.content = content.content.iter().map(|c| c.1.clone()).collect();
self.content = content.content.into_iter().map(|c| c.1).collect();

self.textview.grab_focus();

Expand Down Expand Up @@ -564,7 +564,7 @@ impl Cmdline {

pub fn show(
&mut self,
content: &nvim_bridge::CmdlineShow,
content: nvim_bridge::CmdlineShow,
hl_defs: &HlDefs,
) {
self.input.set_text(content, hl_defs);
Expand Down Expand Up @@ -622,7 +622,7 @@ impl Cmdline {

pub fn block_append(
&mut self,
line: &nvim_bridge::CmdlineBlockAppend,
line: nvim_bridge::CmdlineBlockAppend,
hl_defs: &HlDefs,
) {
self.block.append(line, &hl_defs);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/grid/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl Grid {
});
}

pub fn put_line(&self, line: &GridLineSegment, hl_defs: &HlDefs) {
pub fn put_line(&self, line: GridLineSegment, hl_defs: &HlDefs) {
let mut ctx = self.context.borrow_mut();
let ctx = ctx.as_mut().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/ui/grid/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub fn redraw(
pub fn put_line(
context: &mut Context,
pango_context: &pango::Context,
line: &GridLineSegment,
line: GridLineSegment,
hl_defs: &HlDefs,
) {
let row = line.row as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/ui/grid/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ impl Row {

/// Updates row. `line` should be coming straight from nvim's 'grid_line'.
/// event.
pub fn update(&mut self, line: &GridLineSegment) -> Vec<Segment> {
pub fn update(&mut self, line: GridLineSegment) -> Vec<Segment> {
let col_start = line.col_start as usize;

let mut offset = col_start;
for cell in line.cells.iter() {
for r in 0..cell.repeat as usize {
self.cells[offset + r] = Cell {
// TODO(ville): Avoid clone here?
text: cell.text.clone(),
hl_id: cell.hl_id,
double_width: cell.double_width,
Expand Down Expand Up @@ -504,7 +505,7 @@ mod tests {
],
);

row.update(&GridLineSegment {
row.update(GridLineSegment {
grid: 0,
row: 0,
col_start: 3,
Expand Down
Loading

0 comments on commit 7492a38

Please sign in to comment.