URI: 
       Changed footer styling. - icy_draw - icy_draw is the successor to mystic draw. fork / mirror
  HTML git clone https://git.drkhsh.at/icy_draw.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 27e017be1a73f4d49b4983010ecc2a42bcb4cb29
   DIR parent ae20a71686ddafd0ec6f97f2bb3ecbbba13e26b7
  HTML Author: Mike Krüger <mkrueger@posteo.de>
       Date:   Wed,  9 Aug 2023 11:25:35 +0200
       
       Changed footer styling.
       
       Diffstat:
         M src/model/tools/brush_imp.rs        |       8 +-------
         M src/model/tools/draw_ellipse_fille… |       8 +-------
         M src/model/tools/draw_ellipse_imp.rs |       8 +-------
         M src/model/tools/draw_rectangle_fil… |       8 +-------
         M src/model/tools/draw_rectangle_imp… |       8 +-------
         M src/model/tools/fill_imp.rs         |       8 +-------
         M src/model/tools/line_imp.rs         |       8 +-------
         M src/model/tools/pencil_imp.rs       |      21 ++++++++-------------
         M src/ui/ansi_editor/mod.rs           |     641 ++++++++++++++++---------------
       
       9 files changed, 343 insertions(+), 375 deletions(-)
       ---
   DIR diff --git a/src/model/tools/brush_imp.rs b/src/model/tools/brush_imp.rs
       @@ -149,13 +149,7 @@ impl Tool for BrushTool {
                    );
        
                    if let Some(b) = &buffer_opt {
       -                draw_glyph(
       -                    ui,
       -                    b,
       -                    &mut result,
       -                    &self.char_code,
       -                    self.font_page,
       -                );
       +                draw_glyph(ui, b, &mut result, &self.char_code, self.font_page);
                    }
                });
                ui.radio_value(
   DIR diff --git a/src/model/tools/draw_ellipse_filled_imp.rs b/src/model/tools/draw_ellipse_filled_imp.rs
       @@ -85,13 +85,7 @@ impl Tool for DrawEllipseFilledTool {
                    );
        
                    if let Some(b) = &buffer_opt {
       -                draw_glyph(
       -                    ui,
       -                    b,
       -                    &mut result,
       -                    &self.char_code,
       -                    self.font_page,
       -                );
       +                draw_glyph(ui, b, &mut result, &self.char_code, self.font_page);
                    }
                });
                ui.radio_value(
   DIR diff --git a/src/model/tools/draw_ellipse_imp.rs b/src/model/tools/draw_ellipse_imp.rs
       @@ -85,13 +85,7 @@ impl Tool for DrawEllipseTool {
                    );
        
                    if let Some(b) = &buffer_opt {
       -                draw_glyph(
       -                    ui,
       -                    b,
       -                    &mut result,
       -                    &self.char_code,
       -                    self.font_page,
       -                );
       +                draw_glyph(ui, b, &mut result, &self.char_code, self.font_page);
                    }
                });
                ui.radio_value(
   DIR diff --git a/src/model/tools/draw_rectangle_filled_imp.rs b/src/model/tools/draw_rectangle_filled_imp.rs
       @@ -84,13 +84,7 @@ impl Tool for DrawRectangleFilledTool {
                    );
        
                    if let Some(b) = &buffer_opt {
       -                draw_glyph(
       -                    ui,
       -                    b,
       -                    &mut result,
       -                    &self.char_code,
       -                    self.font_page,
       -                );
       +                draw_glyph(ui, b, &mut result, &self.char_code, self.font_page);
                    }
                });
                ui.radio_value(
   DIR diff --git a/src/model/tools/draw_rectangle_imp.rs b/src/model/tools/draw_rectangle_imp.rs
       @@ -84,13 +84,7 @@ impl Tool for DrawRectangleTool {
                    );
        
                    if let Some(b) = &buffer_opt {
       -                draw_glyph(
       -                    ui,
       -                    b,
       -                    &mut result,
       -                    &self.char_code,
       -                    self.font_page,
       -                );
       +                draw_glyph(ui, b, &mut result, &self.char_code, self.font_page);
                    }
                });
                ui.radio_value(
   DIR diff --git a/src/model/tools/fill_imp.rs b/src/model/tools/fill_imp.rs
       @@ -179,13 +179,7 @@ impl Tool for FillTool {
                    );
        
                    if let Some(b) = &buffer_opt {
       -                draw_glyph(
       -                    ui,
       -                    b,
       -                    &mut result,
       -                    &self.char_code,
       -                    self.font_page,
       -                );
       +                draw_glyph(ui, b, &mut result, &self.char_code, self.font_page);
                    }
                });
                ui.radio_value(
   DIR diff --git a/src/model/tools/line_imp.rs b/src/model/tools/line_imp.rs
       @@ -229,13 +229,7 @@ impl Tool for LineTool {
                    );
        
                    if let Some(b) = &buffer_opt {
       -                draw_glyph(
       -                    ui,
       -                    b,
       -                    &mut result,
       -                    &self.char_code,
       -                    self.font_page,
       -                );
       +                draw_glyph(ui, b, &mut result, &self.char_code, self.font_page);
                    }
                });
                ui.radio_value(
   DIR diff --git a/src/model/tools/pencil_imp.rs b/src/model/tools/pencil_imp.rs
       @@ -148,13 +148,7 @@ impl Tool for PencilTool {
                    );
        
                    if let Some(b) = &buffer_opt {
       -                draw_glyph(
       -                    ui,
       -                    b,
       -                    &mut result,
       -                    &self.char_code,
       -                    self.font_page,
       -                );
       +                draw_glyph(ui, b, &mut result, &self.char_code, self.font_page);
                    }
                });
                ui.radio_value(
       @@ -198,10 +192,11 @@ pub fn draw_glyph_plain(
        ) -> impl egui::Widget {
            move |ui: &mut egui::Ui| {
                let font = &buf.lock().unwrap().editor.buf.font_table[font_page];
       -        let scale = 1.5;
       +        let scale = 1.8;
       +        let padding = 2.;
                let (id, stroke_rect) = ui.allocate_space(Vec2::new(
       -            scale * font.size.width as f32,
       -            scale * font.size.height as f32,
       +            2. * padding + scale * font.size.width as f32,
       +            2. * padding + scale * font.size.height as f32,
                ));
                let mut response = ui.interact(stroke_rect, id, Sense::click());
        
       @@ -221,10 +216,10 @@ pub fn draw_glyph_plain(
                                painter.rect_filled(
                                    Rect::from_min_size(
                                        Pos2::new(
       -                                    stroke_rect.left() + x as f32 * scale,
       -                                    stroke_rect.top() + y as f32 * scale,
       +                                    padding + stroke_rect.left() + x as f32 * scale,
       +                                    padding + stroke_rect.top() + y as f32 * scale,
                                        ),
       -                                Vec2::new(scale, scale),
       +                                Vec2::new(scale.ceil(), scale.ceil()),
                                    ),
                                    Rounding::none(),
                                    col,
   DIR diff --git a/src/ui/ansi_editor/mod.rs b/src/ui/ansi_editor/mod.rs
       @@ -1,6 +1,6 @@
        use eframe::{
       -    egui::{self, Button, CursorIcon, PointerButton, ScrollArea},
       -    epaint::{Pos2, Rect, Vec2},
       +    egui::{self, Button, CursorIcon, PointerButton, RichText, ScrollArea},
       +    epaint::{FontId, Pos2, Rect, Vec2},
        };
        use i18n_embed_fl::fl;
        use icy_engine::{AnsiParser, Buffer, BufferParser, Position, SaveOptions};
       @@ -110,73 +110,115 @@ impl Document for AnsiEditor {
            }
        
            fn show_ui(&mut self, ui: &mut egui_dock::egui::Ui, cur_tool: &mut Box<dyn Tool>) {
       -        ui.vertical(|ui| {
       -            let size = ui.max_rect().size();
       -            let size = Vec2::new(size.x, size.y - 28.0);
       -
       -            ScrollArea::both()
       -                .auto_shrink([false; 2])
       -                .max_height(size.y)
       -                .drag_to_scroll(false)
       -                .show_viewport(ui, |ui, viewport| {
       -                    let (id, draw_area) = ui.allocate_space(size);
       -                    let mut response = ui.interact(draw_area, id, egui::Sense::click());
       -                    let font_dimensions = self
       -                        .buffer_view
       -                        .lock()
       -                        .unwrap()
       -                        .editor
       -                        .buf
       -                        .get_font_dimensions();
       -                    let scale = self.buffer_view.lock().unwrap().scale;
       -                    let real_height = self
       -                        .buffer_view
       -                        .lock()
       -                        .unwrap()
       -                        .editor
       -                        .buf
       -                        .get_real_buffer_height();
       -
       -                    self.buffer_view
       -                        .lock()
       -                        .unwrap()
       -                        .editor
       -                        .buf
       -                        .terminal_state
       -                        .height = min(
       -                        real_height,
       -                        (draw_area.height() / (font_dimensions.height as f32 * scale)).ceil()
       -                            as i32,
       -                    );
       -
       -                    let buf_w = self
       -                        .buffer_view
       -                        .lock()
       -                        .unwrap()
       -                        .editor
       -                        .buf
       -                        .get_buffer_width();
       -                    let buf_h = self
       -                        .buffer_view
       -                        .lock()
       -                        .unwrap()
       -                        .editor
       -                        .buf
       -                        .get_buffer_height();
       -
       -                    let char_size = Vec2::new(
       -                        font_dimensions.width as f32 * scale,
       -                        font_dimensions.height as f32 * scale,
       -                    );
       +        let size = ui.max_rect().size();
       +        let size = Vec2::new(size.x, size.y - 36.0);
       +
       +        ScrollArea::both()
       +            .auto_shrink([false; 2])
       +            .max_height(size.y)
       +            .drag_to_scroll(false)
       +            .show_viewport(ui, |ui, viewport| {
       +                let (id, draw_area) = ui.allocate_space(size);
       +                let mut response = ui.interact(draw_area, id, egui::Sense::click());
       +                let font_dimensions = self
       +                    .buffer_view
       +                    .lock()
       +                    .unwrap()
       +                    .editor
       +                    .buf
       +                    .get_font_dimensions();
       +                let scale = self.buffer_view.lock().unwrap().scale;
       +                let real_height = self
       +                    .buffer_view
       +                    .lock()
       +                    .unwrap()
       +                    .editor
       +                    .buf
       +                    .get_real_buffer_height();
        
       -                    let rect_w = buf_w as f32 * char_size.x;
       -                    let rect_h = buf_h as f32 * char_size.y;
       -                    let top_margin_height = ui.min_rect().top();
       +                self.buffer_view
       +                    .lock()
       +                    .unwrap()
       +                    .editor
       +                    .buf
       +                    .terminal_state
       +                    .height = min(
       +                    real_height,
       +                    (draw_area.height() / (font_dimensions.height as f32 * scale)).ceil() as i32,
       +                );
        
       -                    let rect_h = min(rect_h as i32, draw_area.height() as i32) as f32;
       +                let buf_w = self
       +                    .buffer_view
       +                    .lock()
       +                    .unwrap()
       +                    .editor
       +                    .buf
       +                    .get_buffer_width();
       +                let buf_h = self
       +                    .buffer_view
       +                    .lock()
       +                    .unwrap()
       +                    .editor
       +                    .buf
       +                    .get_buffer_height();
        
       -                    let relative_rect = Rect::from_min_size(
       -                        Pos2::new(
       +                let char_size = Vec2::new(
       +                    font_dimensions.width as f32 * scale,
       +                    font_dimensions.height as f32 * scale,
       +                );
       +
       +                let rect_w = buf_w as f32 * char_size.x;
       +                let rect_h = buf_h as f32 * char_size.y;
       +                let top_margin_height = ui.min_rect().top();
       +
       +                let rect_h = min(rect_h as i32, draw_area.height() as i32) as f32;
       +
       +                let relative_rect = Rect::from_min_size(
       +                    Pos2::new(
       +                        if rect_w < draw_area.width() {
       +                            (draw_area.width() - rect_w) / 2.
       +                        } else {
       +                            0.
       +                        },
       +                        if rect_h < draw_area.height() {
       +                            (draw_area.height() - rect_h) / 2.
       +                        } else {
       +                            0.
       +                        },
       +                    )
       +                    .ceil(),
       +                    Vec2::new(rect_w, rect_h),
       +                );
       +
       +                let max_lines = max(0, real_height - buf_h);
       +                ui.set_height(scale * max_lines as f32 * font_dimensions.height as f32);
       +                ui.set_width(rect_w);
       +                let first_line = (viewport.top() / char_size.y) as i32;
       +
       +                if first_line != self.buffer_view.lock().unwrap().scroll_first_line {
       +                    self.buffer_view.lock().unwrap().scroll_first_line = first_line;
       +                    self.buffer_view.lock().unwrap().redraw_view();
       +                }
       +
       +                let buffer_view = self.buffer_view.clone();
       +                let callback = egui::PaintCallback {
       +                    rect: draw_area,
       +                    callback: std::sync::Arc::new(egui_glow::CallbackFn::new(
       +                        move |info, painter| {
       +                            buffer_view.lock().unwrap().update_buffer(painter.gl());
       +                            buffer_view.lock().unwrap().paint(
       +                                painter.gl(),
       +                                info,
       +                                draw_area,
       +                                relative_rect,
       +                            );
       +                        },
       +                    )),
       +                };
       +
       +                let rect = Rect::from_min_size(
       +                    draw_area.left_top()
       +                        + Vec2::new(
                                    if rect_w < draw_area.width() {
                                        (draw_area.width() - rect_w) / 2.
                                    } else {
       @@ -186,281 +228,254 @@ impl Document for AnsiEditor {
                                        (draw_area.height() - rect_h) / 2.
                                    } else {
                                        0.
       -                            },
       +                            } - draw_area.left_top().y,
                                )
                                .ceil(),
       -                        Vec2::new(rect_w, rect_h),
       -                    );
       -
       -                    let max_lines = max(0, real_height - buf_h);
       -                    ui.set_height(scale * max_lines as f32 * font_dimensions.height as f32);
       -                    ui.set_width(rect_w);
       -                    let first_line = (viewport.top() / char_size.y) as i32;
       -
       -                    if first_line != self.buffer_view.lock().unwrap().scroll_first_line {
       -                        self.buffer_view.lock().unwrap().scroll_first_line = first_line;
       -                        self.buffer_view.lock().unwrap().redraw_view();
       -                    }
       +                    Vec2::new(rect_w, rect_h),
       +                );
       +
       +                ui.painter().add(callback);
       +                response = response
       +                    .context_menu(|ui| terminal_context_menu(&mut self.buffer_view.clone(), ui));
       +                if self.enabled {
       +                    let events = ui.input(|i| i.events.clone());
       +                    for e in &events {
       +                        match e {
       +                            egui::Event::Copy => {
       +                                let buffer_view = self.buffer_view.clone();
       +                                let mut l = buffer_view.lock().unwrap();
       +                                if let Some(txt) = l.get_copy_text(&*self.buffer_parser) {
       +                                    ui.output_mut(|o| o.copied_text = txt);
       +                                }
       +                            }
       +                            egui::Event::Cut => {}
       +                            egui::Event::Paste(text) => {
       +                                self.output_string(text);
       +                                self.buffer_view.lock().unwrap().redraw_view();
       +                            }
        
       -                    let buffer_view = self.buffer_view.clone();
       -                    let callback = egui::PaintCallback {
       -                        rect: draw_area,
       -                        callback: std::sync::Arc::new(egui_glow::CallbackFn::new(
       -                            move |info, painter| {
       -                                buffer_view.lock().unwrap().update_buffer(painter.gl());
       -                                buffer_view.lock().unwrap().paint(
       -                                    painter.gl(),
       -                                    info,
       -                                    draw_area,
       -                                    relative_rect,
       -                                );
       -                            },
       -                        )),
       -                    };
       -
       -                    let rect = Rect::from_min_size(
       -                        draw_area.left_top()
       -                            + Vec2::new(
       -                                if rect_w < draw_area.width() {
       -                                    (draw_area.width() - rect_w) / 2.
       -                                } else {
       -                                    0.
       -                                },
       -                                if rect_h < draw_area.height() {
       -                                    (draw_area.height() - rect_h) / 2.
       -                                } else {
       -                                    0.
       -                                } - draw_area.left_top().y,
       -                            )
       -                            .ceil(),
       -                        Vec2::new(rect_w, rect_h),
       -                    );
       -
       -                    ui.painter().add(callback);
       -                    response = response.context_menu(|ui| {
       -                        terminal_context_menu(&mut self.buffer_view.clone(), ui)
       -                    });
       -                    if self.enabled {
       -                        let events = ui.input(|i| i.events.clone());
       -                        for e in &events {
       -                            match e {
       -                                egui::Event::Copy => {
       +                            egui::Event::CompositionEnd(text) | egui::Event::Text(text) => {
       +                                for c in text.chars() {
                                            let buffer_view = self.buffer_view.clone();
       -                                    let mut l = buffer_view.lock().unwrap();
       -                                    if let Some(txt) = l.get_copy_text(&*self.buffer_parser) {
       -                                        ui.output_mut(|o| o.copied_text = txt);
       -                                    }
       -                                }
       -                                egui::Event::Cut => {}
       -                                egui::Event::Paste(text) => {
       -                                    self.output_string(text);
       -                                    self.buffer_view.lock().unwrap().redraw_view();
       +                                    cur_tool.handle_key(
       +                                        buffer_view,
       +                                        MKey::Character(c as u16),
       +                                        MModifiers::None,
       +                                    );
                                        }
       +                                response.mark_changed();
       +                            }
        
       -                                egui::Event::CompositionEnd(text) | egui::Event::Text(text) => {
       -                                    for c in text.chars() {
       -                                        let buffer_view = self.buffer_view.clone();
       -                                        cur_tool.handle_key(
       -                                            buffer_view,
       -                                            MKey::Character(c as u16),
       -                                            MModifiers::None,
       -                                        );
       -                                    }
       -                                    response.mark_changed();
       +                            egui::Event::PointerButton {
       +                                pos,
       +                                button,
       +                                pressed: true,
       +                                ..
       +                            } => {
       +                                if rect.contains(*pos) {
       +                                    let buffer_view = self.buffer_view.clone();
       +                                    let click_pos = calc_click_pos(
       +                                        pos,
       +                                        rect,
       +                                        top_margin_height,
       +                                        char_size,
       +                                        first_line,
       +                                    );
       +                                    let b = match button {
       +                                        PointerButton::Primary => 1,
       +                                        PointerButton::Secondary => 2,
       +                                        PointerButton::Middle => 3,
       +                                        PointerButton::Extra1 => 4,
       +                                        PointerButton::Extra2 => 5,
       +                                    };
       +                                    self.pressed_button = b;
       +                                    self.drag_start =
       +                                        Position::new(click_pos.x as i32, click_pos.y as i32);
       +                                    self.drag_pos = self.drag_start;
       +                                    cur_tool.handle_click(buffer_view, b, self.drag_start);
                                        }
       +                            }
        
       -                                egui::Event::PointerButton {
       -                                    pos,
       -                                    button,
       -                                    pressed: true,
       -                                    ..
       -                                } => {
       -                                    if rect.contains(*pos) {
       -                                        let buffer_view = self.buffer_view.clone();
       -                                        let click_pos = calc_click_pos(
       -                                            pos,
       -                                            rect,
       -                                            top_margin_height,
       -                                            char_size,
       -                                            first_line,
       -                                        );
       -                                        let b = match button {
       -                                            PointerButton::Primary => 1,
       -                                            PointerButton::Secondary => 2,
       -                                            PointerButton::Middle => 3,
       -                                            PointerButton::Extra1 => 4,
       -                                            PointerButton::Extra2 => 5,
       -                                        };
       -                                        self.pressed_button = b;
       -                                        self.drag_start =
       -                                            Position::new(click_pos.x as i32, click_pos.y as i32);
       -                                        self.drag_pos = self.drag_start;
       -                                        cur_tool.handle_click(buffer_view, b, self.drag_start);
       -                                    }
       +                            egui::Event::PointerButton {
       +                                pos,
       +                                pressed: false,
       +                                ..
       +                            } => {
       +                                if rect.contains(*pos) {
       +                                    self.pressed_button = -1;
       +                                    let buffer_view = self.buffer_view.clone();
       +                                    let click_pos = calc_click_pos(
       +                                        pos,
       +                                        rect,
       +                                        top_margin_height,
       +                                        char_size,
       +                                        first_line,
       +                                    );
       +                                    cur_tool.handle_drag_end(
       +                                        buffer_view,
       +                                        self.drag_start,
       +                                        Position::new(click_pos.x as i32, click_pos.y as i32),
       +                                    );
                                        }
       +                            }
        
       -                                egui::Event::PointerButton {
       -                                    pos,
       -                                    pressed: false,
       -                                    ..
       -                                } => {
       -                                    if rect.contains(*pos) {
       -                                        self.pressed_button = -1;
       -                                        let buffer_view = self.buffer_view.clone();
       -                                        let click_pos = calc_click_pos(
       -                                            pos,
       -                                            rect,
       -                                            top_margin_height,
       -                                            char_size,
       -                                            first_line,
       -                                        );
       -                                        cur_tool.handle_drag_end(
       -                                            buffer_view,
       -                                            self.drag_start,
       -                                            Position::new(click_pos.x as i32, click_pos.y as i32),
       -                                        );
       +                            egui::Event::PointerMoved(pos) => {
       +                                if rect.contains(*pos) && self.pressed_button >= 0 {
       +                                    let buffer_view = self.buffer_view.clone();
       +                                    let click_pos = calc_click_pos(
       +                                        pos,
       +                                        rect,
       +                                        top_margin_height,
       +                                        char_size,
       +                                        first_line,
       +                                    );
       +                                    let cur = Position::new(click_pos.x as i32, click_pos.y as i32);
       +                                    if self.drag_pos != cur {
       +                                        self.drag_pos = cur;
       +                                        buffer_view.lock().unwrap().redraw_view();
       +                                        cur_tool.handle_drag(buffer_view, self.drag_start, cur);
                                            }
                                        }
       +                            }
        
       -                                egui::Event::PointerMoved(pos) => {
       -                                    if rect.contains(*pos) && self.pressed_button >= 0 {
       -                                        let buffer_view = self.buffer_view.clone();
       -                                        let click_pos = calc_click_pos(
       -                                            pos,
       -                                            rect,
       -                                            top_margin_height,
       -                                            char_size,
       -                                            first_line,
       -                                        );
       -                                        let cur =
       -                                            Position::new(click_pos.x as i32, click_pos.y as i32);
       -                                        if self.drag_pos != cur {
       -                                            self.drag_pos = cur;
       -                                            buffer_view.lock().unwrap().redraw_view();
       -                                            cur_tool.handle_drag(buffer_view, self.drag_start, cur);
       -                                        }
       -                                    }
       +                            /*egui::Event::KeyRepeat { key, modifiers }
       +                            | */
       +                            egui::Event::Key {
       +                                key,
       +                                pressed: true,
       +                                modifiers,
       +                                ..
       +                            } => {
       +                                let mut key_code = *key as u32;
       +                                if modifiers.ctrl || modifiers.command {
       +                                    key_code |= CTRL_MOD;
       +                                }
       +                                if modifiers.shift {
       +                                    key_code |= SHIFT_MOD;
                                        }
        
       -                                /*egui::Event::KeyRepeat { key, modifiers }
       -                                | */
       -                                egui::Event::Key {
       -                                    key,
       -                                    pressed: true,
       -                                    modifiers,
       -                                    ..
       -                                } => {
       -                                    let mut key_code = *key as u32;
       -                                    if modifiers.ctrl || modifiers.command {
       -                                        key_code |= CTRL_MOD;
       -                                    }
       -                                    if modifiers.shift {
       -                                        key_code |= SHIFT_MOD;
       -                                    }
       -
       -                                    let mut modifier: MModifiers = MModifiers::None;
       -                                    if modifiers.ctrl || modifiers.command {
       -                                        modifier = MModifiers::Control;
       -                                    }
       +                                let mut modifier: MModifiers = MModifiers::None;
       +                                if modifiers.ctrl || modifiers.command {
       +                                    modifier = MModifiers::Control;
       +                                }
        
       -                                    if modifiers.shift {
       -                                        modifier = MModifiers::Shift;
       -                                    }
       -                                    for (k, m) in ANSI_KEY_MAP {
       -                                        if *k == key_code {
       -                                            let buffer_view = self.buffer_view.clone();
       -                                            cur_tool.handle_key(buffer_view, *m, modifier);
       -                                            self.buffer_view.lock().unwrap().redraw_view();
       -                                            response.mark_changed();
       -                                            ui.input_mut(|i| i.consume_key(*modifiers, *key));
       -                                            break;
       -                                        }
       +                                if modifiers.shift {
       +                                    modifier = MModifiers::Shift;
       +                                }
       +                                for (k, m) in ANSI_KEY_MAP {
       +                                    if *k == key_code {
       +                                        let buffer_view = self.buffer_view.clone();
       +                                        cur_tool.handle_key(buffer_view, *m, modifier);
       +                                        self.buffer_view.lock().unwrap().redraw_view();
       +                                        response.mark_changed();
       +                                        ui.input_mut(|i| i.consume_key(*modifiers, *key));
       +                                        break;
                                            }
                                        }
       -                                _ => {}
                                    }
       +                            _ => {}
                                }
                            }
       -                    if response.hovered() {
       -                        let hover_pos_opt = ui.input(|i| i.pointer.hover_pos());
       -                        if let Some(hover_pos) = hover_pos_opt {
       -                            if rect.contains(hover_pos) {
       -                                ui.output_mut(|o| o.cursor_icon = CursorIcon::Text);
       -                            }
       +                }
       +                if response.hovered() {
       +                    let hover_pos_opt = ui.input(|i| i.pointer.hover_pos());
       +                    if let Some(hover_pos) = hover_pos_opt {
       +                        if rect.contains(hover_pos) {
       +                            ui.output_mut(|o| o.cursor_icon = CursorIcon::Text);
                                }
                            }
       +                }
        
       -                    response.dragged = false;
       -                    response.drag_released = true;
       -                    response.is_pointer_button_down_on = false;
       -                    response.interact_pointer_pos = None;
       -                    response
       -                });
       +                response.dragged = false;
       +                response.drag_released = true;
       +                response.is_pointer_button_down_on = false;
       +                response.interact_pointer_pos = None;
       +                response
       +            });
        
       -            ui.horizontal(|ui| {
       -                let pos = self.buffer_view.lock().unwrap().editor.caret.get_position();
       -                let width = self
       -                    .buffer_view
       -                    .lock()
       -                    .unwrap()
       -                    .editor
       -                    .buf
       -                    .get_buffer_width();
       -                let height = self
       -                    .buffer_view
       -                    .lock()
       -                    .unwrap()
       -                    .editor
       -                    .buf
       -                    .get_buffer_height();
       +        ui.horizontal(|ui| {
       +            let pos = self.buffer_view.lock().unwrap().editor.caret.get_position();
       +            let width = self
       +                .buffer_view
       +                .lock()
       +                .unwrap()
       +                .editor
       +                .buf
       +                .get_buffer_width();
       +            let height = self
       +                .buffer_view
       +                .lock()
       +                .unwrap()
       +                .editor
       +                .buf
       +                .get_buffer_height();
       +            let label_font_size = 20.0;
       +
       +            ui.vertical(|ui| {
       +                ui.add_space(4.);
       +                ui.label(
       +                    RichText::new(fl!(
       +                        crate::LANGUAGE_LOADER,
       +                        "toolbar-position",
       +                        line = pos.y,
       +                        column = pos.x
       +                    ))
       +                    .font(FontId::proportional(label_font_size)),
       +                );
       +            });
        
       +            ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
       +                let cur_outline = self.buffer_view.lock().unwrap().editor.cur_outline;
       +                let cur_font_page = self.buffer_view.lock().unwrap().editor.cur_font_page;
       +
       +                let button_font_size = 16.0;
       +                if ui
       +                    .selectable_label(
       +                        false,
       +                        RichText::new("▶").font(FontId::proportional(button_font_size)),
       +                    )
       +                    .clicked()
       +                {
       +                    self.buffer_view.lock().unwrap().editor.cur_outline =
       +                        (cur_outline + 1) % DEFAULT_OUTLINE_TABLE.len();
       +                }
       +                ui.label(RichText::new((cur_outline + 1).to_string()).font(FontId::proportional(label_font_size)));
       +
       +                if ui
       +                    .selectable_label(
       +                        false,
       +                        RichText::new("◀").font(FontId::proportional(button_font_size)),
       +                    )
       +                    .clicked()
       +                {
       +                    self.buffer_view.lock().unwrap().editor.cur_outline =
       +                        (cur_outline + DEFAULT_OUTLINE_TABLE.len() - 1)
       +                            % DEFAULT_OUTLINE_TABLE.len();
       +                }
       +
       +                for i in (0..10).rev() {
       +                    let ch = self
       +                        .buffer_view
       +                        .lock()
       +                        .unwrap()
       +                        .editor
       +                        .get_outline_char_code(i)
       +                        .unwrap();
       +                    ui.add(crate::model::pencil_imp::draw_glyph_plain(
       +                        self.buffer_view.clone(),
       +                        unsafe { char::from_u32_unchecked(ch as u32) },
       +                        cur_font_page,
       +                    ));
       +
       +                    ui.label(RichText::new(format!("F{}", i + 1)).font(FontId::proportional(label_font_size)));
       +                }
       +/* 
                        ui.label(fl!(
                            crate::LANGUAGE_LOADER,
       -                    "toolbar-position",
       -                    line = pos.y,
       -                    column = pos.x
       -                ));
       -
       -                ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
       -                    let cur_outline = self.buffer_view.lock().unwrap().editor.cur_outline;
       -                    let cur_font_page = self.buffer_view.lock().unwrap().editor.cur_font_page;
       -
       -                    ui.horizontal(|ui| {
       -                        if ui.add(Button::new("▶").frame(false)).clicked() {
       -                            self.buffer_view.lock().unwrap().editor.cur_outline =
       -                                (cur_outline + 1) % DEFAULT_OUTLINE_TABLE.len();
       -                        }
       -                        ui.label(cur_outline.to_string());
       -                        if ui.add(Button::new("◀").frame(false)).clicked() {
       -                            self.buffer_view.lock().unwrap().editor.cur_outline =
       -                                (cur_outline + DEFAULT_OUTLINE_TABLE.len() - 1)
       -                                    % DEFAULT_OUTLINE_TABLE.len();
       -                        }
       -
       -                        for i in (0..10).rev() {
       -                            let ch = self
       -                                .buffer_view
       -                                .lock()
       -                                .unwrap()
       -                                .editor
       -                                .get_outline_char_code(i)
       -                                .unwrap();
       -                            ui.add(crate::model::pencil_imp::draw_glyph_plain(
       -                                self.buffer_view.clone(),
       -                                unsafe { char::from_u32_unchecked(ch as u32) },
       -                                cur_font_page,
       -                            ));
       -                            ui.label(format!("F{}", i + 1));
       -                        }
       -
       -                        ui.label(fl!(
       -                            crate::LANGUAGE_LOADER,
       -                            "toolbar-size",
       -                            colums = width,
       -                            rows = height
       -                        ));
       -                    });
       -                });
       +                    "toolbar-size",
       +                    colums = width,
       +                    rows = height
       +                ));*/
                    });
                });
            }