From 67dc3cd6fcf41e39f8207dd6ddce32ef52b4867a Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Fri, 15 May 2020 22:00:20 +0000 Subject: [PATCH] Quark v0.3: generate buffer only for visible items, handle selection on key move, bugfixes git-svn-id: svn://kolibrios.org@7924 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/lib/list_box.h | 19 +++++--- programs/cmm/quark/data.h | 8 ++-- programs/cmm/quark/prepare_page.h | 37 ++++++--------- programs/cmm/quark/quark.c | 63 +++++++++++++------------- programs/cmm/quark/selection.h | 23 ++++++---- skins/_old/MetalColor/MCRed/MCRed.dtp | Bin 40 -> 40 bytes 6 files changed, 75 insertions(+), 75 deletions(-) diff --git a/programs/cmm/lib/list_box.h b/programs/cmm/lib/list_box.h index c326244a8a..6a6348aba7 100644 --- a/programs/cmm/lib/list_box.h +++ b/programs/cmm/lib/list_box.h @@ -126,13 +126,18 @@ struct llist :int llist::ProcessKey(dword key) { - if (horisontal_selelection) switch(key) - { - case SCAN_CODE_LEFT: return KeyLeft(); - case SCAN_CODE_RIGHT: return KeyRight(); - case SCAN_CODE_HOME: return KeyHomeHor(); - case SCAN_CODE_END: return KeyEndHor(); - } + if (horisontal_selelection) { + if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) switch(key) { + case SCAN_CODE_HOME: KeyHome(); break; + case SCAN_CODE_END: KeyEnd(); + } + switch(key) { + case SCAN_CODE_LEFT: return KeyLeft(); + case SCAN_CODE_RIGHT: return KeyRight(); + case SCAN_CODE_HOME: return KeyHomeHor(); + case SCAN_CODE_END: return KeyEndHor(); + } + } switch(key) { case SCAN_CODE_DOWN: return KeyDown(); diff --git a/programs/cmm/quark/data.h b/programs/cmm/quark/data.h index 92c9251216..45d1035a06 100644 --- a/programs/cmm/quark/data.h +++ b/programs/cmm/quark/data.h @@ -9,11 +9,11 @@ char short_app_name[] = "Quark"; #ifdef LANG_RUS char intro[] = "Это простой просмотрщик текста. -Попробуйте открыть какой-нибудь текстовый файл."; +Попробуйте открыть текстовый файл."; char copied_chars[] = "Скопировано сиволов: %i"; -char about[] = "Quark Text v0.2 +char about[] = "Quark Text v0.4 Автор: Кирилл Липатов aka Leency Сайт: http://aspero.pro @@ -44,12 +44,12 @@ char rmb_menu[] = #else -char intro[] = "Quark will be a nice Code Editor one day. +char intro[] = "Quark is a simple text viewer. Try to open some text file."; char copied_chars[] = "Copied %i chars"; -char about[] = "Quark Text v0.2 +char about[] = "Quark Text v0.4 Author: Kiril Lipatov aka Leency Website: http://aspero.pro diff --git a/programs/cmm/quark/prepare_page.h b/programs/cmm/quark/prepare_page.h index 55cd554f7b..6746d69fd4 100644 --- a/programs/cmm/quark/prepare_page.h +++ b/programs/cmm/quark/prepare_page.h @@ -2,19 +2,13 @@ void ParseAndPaint() { //search.clear(); - list.KeyHome(); list.count=0; + selection.cancel(); Parse(); list.visible = list.h / list.item_h; - if (list.count < list.visible) { - DrawBuf.bufh = list.visible; - } else { - DrawBuf.bufh = list.count; - } - - DrawBuf.Init(list.x, list.y, list.w, DrawBuf.bufh+1*list.item_h); + DrawBuf.Init(list.x, list.y, list.w, list.visible+1*list.item_h); DrawPage(); } @@ -28,7 +22,6 @@ dword buflen = strlen(io.buffer_data) + io.buffer_data; lines.drop(); lines.add(io.buffer_data); - selection.cancel(); for (off = io.buffer_data; off < buflen; off++) { @@ -54,33 +47,33 @@ dword buflen = strlen(io.buffer_data) + io.buffer_data; void PaintVisible() { int i; - dword y; + dword ydraw, absolute_y; dword line_bg; - bool swapped = false; + bool swapped_selection = false; list.column_max = lines.get(list.cur_y+1) - lines.get(list.cur_y); list.CheckDoesValuesOkey(); if (selection.end_offset < selection.start_offset) { - swapped = selection.swap_start_end(); + swapped_selection = selection.swap_start_end(); } - for ( i=list.first; i < list.first+list.visible+1; i++) + for ( i=0; i < list.visible+1; i++) { - y = i * list.item_h; + ydraw = i * list.item_h; + absolute_y = i + list.first; line_bg = theme.bg; - if (selection.start_y < i) && (selection.end_y > i) line_bg = selection.color; - DrawBuf.DrawBar(0, y, list.w, list.item_h, line_bg); + if (selection.start_y < absolute_y) && (selection.end_y > absolute_y) line_bg = selection.color; + DrawBuf.DrawBar(0, ydraw, list.w, list.item_h, line_bg); - selection.draw(i); + selection.draw(absolute_y); - if (i= list.first) && (list.cur_y <= list.first+list.visible) { + DrawBuf.DrawBar(list.cur_x * list.font_w + 2, list.cur_y - list.first * list.item_h, 2, list.item_h, theme.cursor); + } } void SELECTION::cancel() @@ -49,6 +52,7 @@ void SELECTION::cancel() void SELECTION::set_start() { + if (selection.is_active()) return; start_x = list.cur_x; start_y = list.cur_y; normalize(); @@ -61,8 +65,8 @@ void SELECTION::set_end() end_y = list.cur_y; normalize(); end_offset = lines.get(end_y) + end_x; - debugval("end_x", end_x); - debugval("end_y", end_y); + //debugval("end_x", end_x); + //debugval("end_y", end_y); } @@ -78,11 +82,10 @@ void SELECTION::select_all() start_x = 0; end_y = lines.count-2; end_x = lines.get(end_y+1) - lines.get(end_y); - //normalize(); start_offset = lines.get(start_y) + start_x; end_offset = lines.get(end_y) + end_x; - debugval("end_x__", end_x); - debugval("end_y__", end_y); + //debugval("end_x__", end_x); + //debugval("end_y__", end_y); } bool SELECTION::swap_start_end() diff --git a/skins/_old/MetalColor/MCRed/MCRed.dtp b/skins/_old/MetalColor/MCRed/MCRed.dtp index dc1750320d636c7da285687bbce78a59d6349ad9..45597655160af053a75be4fc93e7f9df418e84ff 100644 GIT binary patch delta 21 acmdPU;I}kc&j7-AFJELhaNxj1en|jJwFnXb literal 40 fcmcCCS