forked from KolibriOS/kolibrios
Quark v0.7
git-svn-id: svn://kolibrios.org@7941 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
d23d7c335a
commit
97e06fdb45
@ -102,21 +102,21 @@ struct llist
|
||||
|
||||
:int llist::ProcessMouse(int xx, yy)
|
||||
{
|
||||
int cur_y_temp, cur_x_temp, ret=0;
|
||||
int new_cur_y, new_cur_x, ret=0;
|
||||
if (MouseOver(xx, yy))
|
||||
{
|
||||
cur_y_temp = yy - y / item_h + first;
|
||||
if (cur_y_temp != cur_y) && (cur_y_temp<count)
|
||||
new_cur_y = yy - y / item_h + first;
|
||||
if (new_cur_y != cur_y) && (new_cur_y<count)
|
||||
{
|
||||
cur_y = cur_y_temp;
|
||||
cur_y = new_cur_y;
|
||||
ret = 1;
|
||||
}
|
||||
if (horisontal_selelection)
|
||||
{
|
||||
cur_x_temp = xx - x / item_w;
|
||||
if (cur_x_temp != cur_x) && (cur_x_temp<column_max)
|
||||
new_cur_x = xx - x / item_w;
|
||||
if (new_cur_x != cur_x) && (new_cur_x<column_max)
|
||||
{
|
||||
cur_x = cur_x_temp;
|
||||
cur_x = new_cur_x;
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
|
@ -491,6 +491,18 @@ LS3:
|
||||
}
|
||||
}
|
||||
|
||||
inline int strnum(dword haystack, needle)
|
||||
{
|
||||
int count = 0;
|
||||
int needle_len = strlen(needle);
|
||||
loop() {
|
||||
if (! haystack = strstr(haystack, needle)) break;
|
||||
haystack+=needle_len;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
inline signed int strcmpi(dword cmp1, cmp2)
|
||||
{
|
||||
char si, ue;
|
||||
|
@ -13,7 +13,7 @@ char intro[] = "
|
||||
|
||||
char copied_chars[] = "‘ª®¯¨à®¢ ® ᨢ®«®¢: %i";
|
||||
|
||||
char about[] = "Quark Text v0.4
|
||||
char about[] = "Quark Text v0.7
|
||||
€¢â®à: Š¨à¨«« ‹¨¯ ⮢ aka Leency
|
||||
‘ ©â: http://aspero.pro
|
||||
|
||||
@ -31,8 +31,8 @@ F3 -
|
||||
Esc - áªàëâì ¯ ¥«ì ¯®¨áª ";
|
||||
|
||||
char color_scheme_names[] = "’¢®à®¦¥ª\nŠ®á¬®á ";
|
||||
#define FILE_SAVED_WELL "'” ©« ãá¯¥è® á®åà ¥'O"
|
||||
#define FILE_NOT_SAVED "'Žè¨¡ª ¯à¨ á®åà ¥¨¨ ä ©« !'E"
|
||||
?define FILE_SAVED_WELL "'” ©« ãá¯¥è® á®åà ¥'O"
|
||||
?define FILE_NOT_SAVED "'Žè¨¡ª ¯à¨ á®åà ¥¨¨ ä ©« !'E"
|
||||
|
||||
char rmb_menu[] =
|
||||
"‚ë१ âì|Ctrl+X
|
||||
@ -42,6 +42,9 @@ char rmb_menu[] =
|
||||
Žâªàëâì ¢ ¯ ¯ª¥
|
||||
Š®¯¨à®¢ âì ¯ãâì ä ©« ";
|
||||
|
||||
?define T_MATCHES "<EFBFBD> ©¤¥®: %i "
|
||||
?define T_FIND_NEXT "<EFBFBD> ©â¨ ¤ «¥¥"
|
||||
|
||||
#else
|
||||
|
||||
char intro[] = "Quark is a simple text viewer.
|
||||
@ -49,7 +52,7 @@ Try to open some text file.";
|
||||
|
||||
char copied_chars[] = "Copied %i chars";
|
||||
|
||||
char about[] = "Quark Text v0.4
|
||||
char about[] = "Quark Text v0.7
|
||||
Author: Kiril Lipatov aka Leency
|
||||
Website: http://aspero.pro
|
||||
|
||||
@ -67,8 +70,8 @@ F3 - search next
|
||||
Esc - hide search bar";
|
||||
|
||||
char color_scheme_names[] = "Dairy\nCosmos ";
|
||||
#define FILE_SAVED_WELL "'File saved'O"
|
||||
#define FILE_NOT_SAVED "'Error saving file!'E"
|
||||
?define FILE_SAVED_WELL "'File saved'O"
|
||||
?define FILE_NOT_SAVED "'Error saving file!'E"
|
||||
|
||||
char rmb_menu[] =
|
||||
"Cut|Ctrl+X
|
||||
@ -78,6 +81,9 @@ Paste|Ctrl+V
|
||||
Reveal in folder
|
||||
Copy file path";
|
||||
|
||||
?define T_MATCHES "Matches: %i "
|
||||
?define T_FIND_NEXT " Find next "
|
||||
|
||||
#endif
|
||||
|
||||
//===================================================//
|
||||
|
@ -57,7 +57,7 @@ int font_size;
|
||||
|
||||
#include "data.h"
|
||||
|
||||
#include "../txtread/search.h"
|
||||
#include "search.h"
|
||||
#include "selection.h"
|
||||
#include "prepare_page.h"
|
||||
|
||||
@ -72,8 +72,6 @@ scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,
|
||||
|
||||
char title[4196];
|
||||
|
||||
bool help_opened = false;
|
||||
|
||||
int reopenin_mx,
|
||||
theme_mx,
|
||||
burger_mx,
|
||||
@ -197,18 +195,33 @@ void HandleButtonEvent()
|
||||
|
||||
void HandleKeyEvent()
|
||||
{
|
||||
int new_y;
|
||||
if (help_opened) {
|
||||
help_opened = false;
|
||||
DrawPage();
|
||||
return;
|
||||
}
|
||||
GetKeys();
|
||||
|
||||
switch (key_scancode)
|
||||
{
|
||||
case SCAN_CODE_F1:
|
||||
EventShowInfo();
|
||||
return;
|
||||
case SCAN_CODE_ESC:
|
||||
search.hide();
|
||||
return;
|
||||
case SCAN_CODE_ENTER:
|
||||
if (! search_box.flags & ed_focus) return;
|
||||
case SCAN_CODE_F3:
|
||||
EventSearchNext();
|
||||
return;
|
||||
}
|
||||
|
||||
if (search.edit_key()) return;
|
||||
|
||||
if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
|
||||
if (key.press(ECTRL + key_scancode)) return;
|
||||
switch (key_scancode)
|
||||
{
|
||||
case SCAN_CODE_KEY_A:
|
||||
selection.select_all();
|
||||
DrawPage();
|
||||
return;
|
||||
case SCAN_CODE_KEY_X:
|
||||
EventCut();
|
||||
return;
|
||||
@ -230,36 +243,18 @@ void HandleKeyEvent()
|
||||
case SCAN_CODE_KEY_F:
|
||||
search.show();
|
||||
return;
|
||||
case SCAN_CODE_KEY_A:
|
||||
selection.select_all();
|
||||
DrawPage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (key_scancode)
|
||||
{
|
||||
case SCAN_CODE_F1:
|
||||
EventShowInfo();
|
||||
return;
|
||||
case SCAN_CODE_ESC:
|
||||
search.hide();
|
||||
return;
|
||||
case SCAN_CODE_ENTER:
|
||||
if (! search_box.flags & ed_focus) return;
|
||||
case SCAN_CODE_F3:
|
||||
EventSearchNext();
|
||||
return;
|
||||
}
|
||||
if (search.edit_key()) {
|
||||
return;
|
||||
|
||||
if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
|
||||
selection.set_start();
|
||||
} else {
|
||||
if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_start();
|
||||
else selection.cancel();
|
||||
if (list.ProcessKey(key_scancode)) {
|
||||
if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_end();
|
||||
DrawPage();
|
||||
}
|
||||
return;
|
||||
selection.cancel();
|
||||
}
|
||||
|
||||
if (list.ProcessKey(key_scancode)) {
|
||||
if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_end();
|
||||
DrawPage();
|
||||
}
|
||||
//EventInsertCharIntoText();
|
||||
}
|
||||
@ -284,7 +279,11 @@ void HandleMouseEvent()
|
||||
return;
|
||||
}
|
||||
|
||||
//as we have lines of variable width, we need to recalculate column_max
|
||||
list.column_max = lines.len(mouse.y - list.y / list.item_h + list.first);
|
||||
|
||||
list.ProcessMouse(mouse.x, mouse.y);
|
||||
|
||||
if (mouse.down) {
|
||||
selection.cancel();
|
||||
selection.set_start();
|
||||
@ -313,7 +312,7 @@ void HandleMouseEvent()
|
||||
|
||||
bool EventSearchNext()
|
||||
{
|
||||
int new_y = search.find_next(list.first, theme.bg);
|
||||
int new_y = search.find_next(list.first);
|
||||
if (new_y) {
|
||||
list.first = new_y / list.item_h;
|
||||
list.CheckDoesValuesOkey();
|
||||
|
118
programs/cmm/quark/search.h
Normal file
118
programs/cmm/quark/search.h
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
#define SEARCH_H 34
|
||||
|
||||
|
||||
struct SEARCH
|
||||
{
|
||||
bool visible;
|
||||
int found_count;
|
||||
void show();
|
||||
void hide();
|
||||
bool draw();
|
||||
void draw_found();
|
||||
int height();
|
||||
bool edit_key();
|
||||
bool edit_mouse();
|
||||
void clear();
|
||||
int find_next();
|
||||
} search;
|
||||
|
||||
char found_text[64];
|
||||
|
||||
char search_text[64];
|
||||
edit_box search_box = {250, 10, NULL, 0xffffff,
|
||||
0x94AECE, 0xffffff, 0xffffff,0x10000000,sizeof(search_text)-1,#search_text};
|
||||
|
||||
|
||||
void SEARCH::show()
|
||||
{
|
||||
visible = true;
|
||||
search_box.flags = ed_focus;
|
||||
draw_window();
|
||||
}
|
||||
|
||||
void SEARCH::hide()
|
||||
{
|
||||
visible = false;
|
||||
draw_window();
|
||||
}
|
||||
|
||||
int SEARCH::height()
|
||||
{
|
||||
return visible * SEARCH_H;
|
||||
}
|
||||
|
||||
bool SEARCH::edit_key()
|
||||
{
|
||||
if (visible) && (search_box.flags & ed_focus) {
|
||||
EAX = key_editbox;
|
||||
edit_box_key stdcall(#search_box);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SEARCH::edit_mouse()
|
||||
{
|
||||
if (visible) {
|
||||
edit_box_mouse stdcall(#search_box);
|
||||
if (search_box.flags & ed_focus) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SEARCH::draw_found()
|
||||
{
|
||||
char matches[30];
|
||||
sprintf(#matches, T_MATCHES, found_count);
|
||||
WriteTextWithBg(search_box.left+search_box.width+14+110,
|
||||
search_box.top+3, 0xD0, sc.work_text, #matches, sc.work);
|
||||
}
|
||||
|
||||
bool SEARCH::draw(dword _btn_find, _btn_hide, _y)
|
||||
{
|
||||
if (!visible) return false;
|
||||
DrawBar(0, _y, Form.cwidth, 1, sc.work_graph);
|
||||
DrawBar(0, _y+1, Form.cwidth, SEARCH_H-1, sc.work);
|
||||
|
||||
search_box.top = _y + 6;
|
||||
search_box.width = math.min(Form.width - 200, 250);
|
||||
|
||||
DrawRectangle(search_box.left-1, search_box.top-1, search_box.width+2, 23,sc.work_graph);
|
||||
|
||||
edit_box_draw stdcall(#search_box);
|
||||
|
||||
DrawCaptButton(search_box.left+search_box.width+14, search_box.top-1, 90,
|
||||
TOOLBAR_ICON_HEIGHT+1, _btn_find, sc.work_light, sc.work_text, T_FIND_NEXT);
|
||||
|
||||
draw_found();
|
||||
|
||||
DefineHiddenButton(Form.cwidth-26, search_box.top-1, TOOLBAR_ICON_HEIGHT+1,
|
||||
TOOLBAR_ICON_HEIGHT+1, _btn_hide);
|
||||
WriteText(Form.cwidth-26+7, search_box.top+2, 0x81, sc.work_graph, "x");
|
||||
return true;
|
||||
}
|
||||
|
||||
void SEARCH::clear()
|
||||
{
|
||||
visible = false;
|
||||
found_text[0] = '\0';
|
||||
found_count = 0;
|
||||
}
|
||||
|
||||
int SEARCH::find_next(int _cur_pos)
|
||||
{
|
||||
int i;
|
||||
if (!search_text[0]) return false;
|
||||
|
||||
strcpy(#found_text, #search_text);
|
||||
//highlight(0xFF0000, _bg_color);
|
||||
found_count = strnum(io.buffer_data, #found_text);
|
||||
draw_found();
|
||||
|
||||
for (i=_cur_pos+1; i<list.count; i++) {
|
||||
if (strstri(lines.get(i),#search_text)!=-1) return atoi(lines.get(i));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ struct SELECTION {
|
||||
bool swap_start_end();
|
||||
void normalize();
|
||||
void select_all();
|
||||
void debug();
|
||||
} selection;
|
||||
|
||||
bool SELECTION::is_active()
|
||||
@ -33,6 +34,7 @@ void SELECTION::draw(int i)
|
||||
if (start_y == i) && (end_y == i) draw_line(start_x * list.font_w+2, start_y, end_x - start_x * list.font_w);
|
||||
else if (start_y == i) draw_line(start_x * list.font_w+2, start_y, list.w -2- calc(start_x * list.font_w));
|
||||
else if (end_y == i) draw_line(0, end_y, end_x * list.font_w+2);
|
||||
//only for debug:
|
||||
//DrawBuf.DrawBar(start_x * list.font_w + 2, start_y * list.item_h, 2, list.item_h, 0x00FF00);
|
||||
//DrawBuf.DrawBar(end_x * list.font_w + 0, end_y * list.item_h, 2, list.item_h, 0xFF00FF);
|
||||
}
|
||||
@ -59,14 +61,19 @@ void SELECTION::set_start()
|
||||
start_offset = lines.get(start_y) + start_x;
|
||||
}
|
||||
|
||||
:void SELECTION::debug()
|
||||
{
|
||||
char rez[256];
|
||||
sprintf(#rez, "start_x: %d start_y: %d end_x: %d end_y: %d", start_x, start_y, end_x, end_y);
|
||||
debugln(#rez);
|
||||
}
|
||||
|
||||
void SELECTION::set_end()
|
||||
{
|
||||
end_x = list.cur_x;
|
||||
end_y = list.cur_y;
|
||||
normalize();
|
||||
end_offset = lines.get(end_y) + end_x;
|
||||
//debugval("end_x", end_x);
|
||||
//debugval("end_y", end_y);
|
||||
}
|
||||
|
||||
|
||||
@ -84,8 +91,6 @@ void SELECTION::select_all()
|
||||
end_x = lines.get(end_y+1) - lines.get(end_y);
|
||||
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);
|
||||
}
|
||||
|
||||
bool SELECTION::swap_start_end()
|
||||
|
Loading…
Reference in New Issue
Block a user