renamed txt_cursor to caret

This commit is contained in:
Anton-4 2020-12-30 17:21:21 +01:00
parent dcee932495
commit fb66312a69
4 changed files with 56 additions and 56 deletions

View file

@ -214,7 +214,7 @@ fn run_event_loop() -> Result<(), Box<dyn Error>> {
let glyph_bounds_rects = queue_all_text(
&size,
&ed_model.lines,
ed_model.txt_cursor_pos,
ed_model.caret_pos,
&mut glyph_brush,
);
@ -371,7 +371,7 @@ fn create_render_pipeline(
fn queue_all_text(
size: &winit::dpi::PhysicalSize<u32>,
lines: &[String],
txt_cursor_pos: Position,
caret_pos: Position,
glyph_brush: &mut wgpu_glyph::GlyphBrush<()>,
) -> Vec<Vec<Rect>> {
let area_bounds = (size.width as f32, size.height as f32).into();
@ -394,18 +394,18 @@ fn queue_all_text(
..Default::default()
};
let txt_cursor_pos_label = Text {
let caret_pos_label = Text {
position: (30.0, 530.0).into(),
area_bounds,
color: (0.4666, 0.2, 1.0, 1.0).into(),
text: format!("Ln {}, Col {}", txt_cursor_pos.line, txt_cursor_pos.column),
text: format!("Ln {}, Col {}", caret_pos.line, caret_pos.column),
size: 30.0,
..Default::default()
};
text::queue_text_draw(&main_label, glyph_brush);
text::queue_text_draw(&txt_cursor_pos_label, glyph_brush);
text::queue_text_draw(&caret_pos_label, glyph_brush);
text::queue_text_draw(&code_text, glyph_brush)
}
@ -423,8 +423,8 @@ fn update_text_state(ed_model: &mut model::Model, received_char: &char) {
} else if ed_model.lines.len() > 1 {
ed_model.lines.pop();
}
ed_model.txt_cursor_pos = update::move_txt_cursor_left(
ed_model.txt_cursor_pos,
ed_model.caret_pos = update::move_caret_left(
ed_model.caret_pos,
None,
false,
&ed_model.lines,
@ -441,8 +441,8 @@ fn update_text_state(ed_model: &mut model::Model, received_char: &char) {
last_line.push(*received_char)
}
ed_model.lines.push(String::new());
ed_model.txt_cursor_pos = Position {
line: ed_model.txt_cursor_pos.line + 1,
ed_model.caret_pos = Position {
line: ed_model.caret_pos.line + 1,
column: 0,
};
@ -454,7 +454,7 @@ fn update_text_state(ed_model: &mut model::Model, received_char: &char) {
if let Some(last_line) = ed_model.lines.last_mut() {
last_line.push(*received_char);
ed_model.txt_cursor_pos = Position {
ed_model.caret_pos = Position {
line: nr_lines - 1,
column: last_line.len(),
};