Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8583 → Rev 8584

/programs/cmm/quark/data.h
8,12 → 8,13
 
#ifdef LANG_RUS
 
char intro[] = "â® ¯à®á⮩ ¯à®á¬®âà騪 ⥪áâ .
char intro[] = "â® ¯à®á⮩ ¯à®á¬®âà騪 ¨ । ªâ®à ⥪áâ .
®¯à®¡ã©â¥ ®âªàëâì ⥪áâ®¢ë© ä ©«.";
 
char copied_chars[] = "‘ª®¯¨à®¢ ­® ᨢ®«®¢: %i";
char copied_chars[] = "%i ᨬ¢®«®¢ ᪮¯¨à®¢ ­®";
char chars_selected[] = "%i ᨬ¢®«®¢ ¢ë¤¥«¥­®";
 
char about[] = "Quark Text v0.9
char about[] = "Quark Text v0.95
€¢â®à: Š¨à¨«« ‹¨¯ â®¢ aka Leency
‘ ©â: http://aspero.pro
 
47,12 → 48,13
 
#else
 
char intro[] = "Quark is a simple text viewer.
char intro[] = "Quark is a simple text viewer and editor.
Try to open some text file.";
 
char copied_chars[] = "Copied %i chars";
char copied_chars[] = "%i characters copied";
char chars_selected[] = "%i characters selected";
 
char about[] = "Quark Text v0.91
char about[] = "Quark Text v0.95
Author: Kiril Lipatov aka Leency
Website: http://aspero.pro
 
104,7 → 106,7
} theme;
 
char default_dir[] = "/rd/1";
od_filter filter2 = { 33, "TXT\0ASM\0HTM\0HTML\0C\0H\0C--\0H--\0CPP\0\0" };
od_filter filter2 = { 37, "TXT\0INI\0ASM\0HTM\0HTML\0C\0H\0C--\0H--\0CPP\0\0" };
 
CANVAS canvas;
 
112,6 → 114,8
 
collection_int lines = {0};
 
#define file_path param
 
//===================================================//
// //
// SETTINGS //
123,7 → 127,7
 
void LoadIniSettings()
{
font_size = ini.GetInt("FontSize", 'M');
font_size = ini.GetInt("FontSize", 1);
user_encoding = ini.GetInt("Encoding", CH_AUTO);
curcol_scheme = ini.GetInt("ColorScheme", 0);
Form.left = ini.GetInt("WinX", 150);
/programs/cmm/quark/prepare_page.h
1,9 → 1,6
 
void ParseAndPaint()
{
list.count=0;
selection.cancel();
if (list.w != canvas.bufw) canvas.Init(list.x, list.y, list.w, screen.height);
Parse();
DrawPage();
}
10,36 → 7,67
 
void Parse()
{
dword off;
dword ptr;
int line_end;
dword line_length=0;
dword line_start = io.buffer_data;
dword buflen = strlen(io.buffer_data) + io.buffer_data;
dword line_start = textbuf.p;
 
list.count=0;
selection.cancel();
if (list.w != canvas.bufw) canvas.Init(list.x, list.y, list.w, screen.height);
 
lines.drop();
lines.add(io.buffer_data);
lines.add(textbuf.p);
 
for (off = io.buffer_data; off < buflen; off++)
for (ptr = textbuf.p; ptr < textbuf.p + textbuf.len; ptr++)
{
line_length += list.font_w;
if (line_length + 30 >= list.w) || (ESBYTE[off] == 10)
if (line_length + 30 >= list.w) || (ESBYTE[ptr] == '\n')
{
//if (ESBYTE[ptr+1] == '\r') ptr++;
//searching a 'white' for a normal word-break
for(line_end = off; line_end != line_start; line_end--)
for(line_end = ptr; line_end != line_start; line_end--)
{
if (__isWhite(ESBYTE[line_end])) { off=line_end+1; break; }
if (__isWhite(ESBYTE[line_end])) { ptr=line_end+1; break; }
}
line_length = off - line_start * list.font_w;
line_length = ptr - line_start * list.font_w;
list.count++;
lines.add(off);
line_start = off;
lines.add(ptr);
line_start = ptr;
line_length = 0;
}
}
lines.add(buflen);
lines.add(ptr);
list.count++;
}
 
void DrawPage()
{
char t[64];
scroll.max_area = list.count;
scroll.cur_area = list.visible;
scroll.position = list.first;
scroll.all_redraw = 0;
scroll.start_x = list.x + list.w;
scroll.start_y = list.y;
scroll.size_y = list.h;
 
if (list.count <= list.visible) {
DrawBar(scroll.start_x, scroll.start_y, scroll.size_x,
scroll.size_y, theme.bg);
} else {
scrollbar_v_draw(#scroll);
}
DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x,
scroll.size_y-1, scroll.bckg_col);
 
PaintVisible();
 
sprintf(#t, #chars_selected, math.abs(selection.end_offset - selection.start_offset));
if (selection.is_active()) DrawStatusBar(#t); else DrawStatusBar(" ");
}
 
void PaintVisible()
{
int i, ff;
/programs/cmm/quark/quark.c
4,12 → 4,13
Licence: GPLv2
 
The core components of this app are:
1. list: text grid with keyboard and mouse events
2. lines: the mas of pointers for each line start
3. selection
1. textbuf: page data
2. list: text grid with keyboard and mouse events
3. lines: the mas of pointers for each line start
4. selection
*/
 
#define MEMSIZE 1024*100
#define MEMSIZE 60*1024
 
//===================================================//
// //
43,6 → 44,8
 
proc_info Form;
llist list;
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,
0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
 
#define TOOLBAR_H 38
#define TOOLBAR_ICON_WIDTH 24
55,13 → 58,12
int curcol_scheme;
int font_size;
 
bool enable_edit = false;
bool search_next = false;
 
#include "data.h"
 
#include "textbuf.h"
#include "selection.h"
#include "search.h"
#include "selection.h"
#include "prepare_page.h"
 
//===================================================//
70,9 → 72,6
// //
//===================================================//
 
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,
0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
 
char title[4196];
 
int reopenin_mx,
86,6 → 85,7
COLOR_SCHEME=8,
RMB_MENU,
BTN_FIND_NEXT,
BTN_FIND_PREVIOUS,
BTN_FIND_CLOSE,
BTN_CHANGE_CHARSET
};
113,7 → 113,7
 
void LoadFileFromDocPack()
{
dword bufsize = atoi(#param + 1) + 20;
dword bufsize = atoi(#file_path + 1) + 20;
dword bufpointer = malloc(bufsize);
 
ESDWORD[bufpointer+0] = 0;
123,11 → 123,12
SetEventMask(EVM_IPC);
if (@WaitEventTimeout(200) != evIPC) {
notify("'IPC FAIL'E");
return;
} else {
textbuf.set(bufpointer + 16, ESDWORD[bufpointer+12]);
}
 
io.buffer_data = malloc(ESDWORD[bufpointer+12]);
strcpy(io.buffer_data, bufpointer + 16);
free(bufpointer);
file_path[0]='\0';
sprintf(#title, "#DOCPACK - %s", #short_app_name);
}
 
void main()
135,37 → 136,22
InitDlls();
LoadIniSettings();
EventSetColorScheme(curcol_scheme);
if (param[0] == '*') {
if (file_path[0] == '*') {
LoadFileFromDocPack();
param[0]='\0';
sprintf(#title, "#DOCPACK - %s", #short_app_name);
} else {
if (streq(#param,"-new")) {Form.left+=40;Form.top+=40;}
LoadFile(#param);
if (streq(#file_path,"-new")) {Form.left+=40;Form.top+=40;}
LoadFile(#file_path);
}
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
loop()
loop() switch(@WaitEventTimeout(400))
{
switch(@WaitEventTimeout(400))
{
case evMouse:
HandleMouseEvent();
break;
case evKey:
HandleKeyEvent();
break;
case evButton:
HandleButtonEvent();
break;
case evReDraw:
if (CheckActiveProcess(Form.ID)) EventMenuClick();
draw_window();
break;
default:
DrawStatusBar(" "); //clean DrawStatusBar text with delay
case evMouse: HandleMouseEvent(); break;
case evKey: HandleKeyEvent(); break;
case evButton: HandleButtonEvent(); break;
case evReDraw: draw_window(); break;
default: DrawStatusBar(" "); //clean DrawStatusBar text with delay
}
}
}
 
//===================================================//
// //
183,15 → 169,10
button.press(btn);
switch(btn-10)
{
case BTN_FIND_NEXT:
EventSearchNext();
break;
case BTN_FIND_CLOSE:
search.hide();
break;
case BTN_CHANGE_CHARSET:
EventShowCharsetsList();
break;
case BTN_FIND_NEXT: EventSearchNext(); break;
case BTN_FIND_PREVIOUS: EventSearchPrevious(); break;
case BTN_FIND_CLOSE: search.hide(); break;
case BTN_CHANGE_CHARSET: EventShowCharsetsList(); break;
}
}
 
208,9 → 189,13
search.hide();
return;
case SCAN_CODE_ENTER:
if (! search_box.flags & ed_focus) return;
if (! search_box.flags & ed_focus) break;
case SCAN_CODE_F3:
if (key_modifier & KEY_LSHIFT) {
EventSearchPrevious();
} else {
EventSearchNext();
}
return;
}
 
220,31 → 205,14
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;
case SCAN_CODE_KEY_C:
EventCopy();
return;
case SCAN_CODE_KEY_V:
EventPaste();
return;
case SCAN_CODE_UP:
EventMagnifyPlus();
return;
case SCAN_CODE_DOWN:
EventMagnifyMinus();
return;
case SCAN_CODE_TAB:
EventShowCharsetsList();
return;
case SCAN_CODE_KEY_F:
search.show();
return;
case SCAN_CODE_KEY_A: EventSelectAllText(); return;
case SCAN_CODE_KEY_X: EventCut(); return;
case SCAN_CODE_KEY_C: EventCopy(); return;
case SCAN_CODE_KEY_V: EventPaste(); return;
case SCAN_CODE_UP: EventMagnifyPlus(); return;
case SCAN_CODE_DOWN: EventMagnifyMinus(); return;
case SCAN_CODE_TAB: EventShowCharsetsList(); return;
case SCAN_CODE_KEY_F: search.show(); return;
}
}
 
251,15 → 219,16
if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
selection.set_start();
} else {
EventInsertCharIntoText();
selection.cancel();
}
 
if (key_scancode == SCAN_CODE_LEFT) && (!list.cur_x) && (list.cur_y) list.column_max = lines.len(list.cur_y-1);
if (list.ProcessKey(key_scancode)) {
if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_end();
DrawPage();
return;
}
if(enable_edit) EventInsertCharIntoText();
}
 
void HandleMouseEvent()
315,9 → 284,8
 
bool EventSearchNext()
{
int new_y = search.find_next(list.first+1);
if (new_y) {
list.first = new_y;
if (search.find_next(list.first+1)) {
list.first = EAX;
list.CheckDoesValuesOkey();
search_next = true;
DrawPage();
324,6 → 292,16
}
}
 
bool EventSearchPrevious()
{
if (search.find_prior(list.first)) {
list.first = EAX;
list.CheckDoesValuesOkey();
search_next = true;
DrawPage();
}
}
 
void EventNewFile()
{
RunProgram(#program_path, "-new");
342,36 → 320,36
{
int res;
char backy_param[4096];
if (io.buffer_data) {
io.dir.make("/tmp0/1/quark_backups");
sprintf(#backy_param, "%s -o /tmp0/1/quark_backups", #param);
io.run("/sys/develop/backy", #backy_param);
if (! io.write(#param, io.buffer_data) ) {
sprintf(#backy_param, "%s -o /tmp0/1/quark_backups", #file_path);
RunProgram("/sys/develop/backy", #backy_param);
if (! WriteFile(0, textbuf.len, textbuf.p, #file_path) ) {
notify(FILE_SAVED_WELL);
} else {
notify(FILE_NOT_SAVED);
}
}
}
 
void EventShowFileInfo()
{
char ss_param[4096];
if (!param) return;
if (!file_path) return;
strcpy(#ss_param, "-p ");
strcpy(#ss_param+3, #param);
strcpy(#ss_param+3, #file_path);
RunProgram("/sys/File managers/Eolite", #ss_param);
}
 
void EventMagnifyMinus()
{
SetSizes('S');
font_size = math.max(0, font_size-1);
SetFontSize(font_size);
ParseAndPaint();
}
 
void EventMagnifyPlus()
{
SetSizes('M');
font_size = math.min(3, font_size+1);
SetFontSize(font_size);
ParseAndPaint();
}
 
419,19 → 397,14
 
 
void EventShowInfo() {
static dword shared_about;
if (!shared_about) {
shared_about = memopen("QUARK_ABOUT", sizeof(about)+1, SHM_OPEN_ALWAYS + SHM_READ);
strcpy(shared_about, #about);
notify(#about);
}
RunProgram("/sys/dialog", "-info 122 *QUARK_ABOUT");
}
 
void EventChangeCharset(dword id)
{
if (param[0]=='\0') return;
if (file_path[0]=='\0') return;
user_encoding = id;
LoadFile(#param);
LoadFile(#file_path);
ParseAndPaint();
draw_window();
}
447,11 → 420,11
case 3: app = "/sys/fb2read"; break;
case 4: app = "/sys/develop/heed"; break;
case 5: open_param[0]='~';
strcpy(#open_param+1,#param);
strcpy(#open_param+1,#file_path);
RunProgram("/sys/@open", #open_param);
return;
}
RunProgram(app, #param);
RunProgram(app, #file_path);
}
 
void EventMenuClick()
480,6 → 453,7
 
void EventInsertCharIntoText()
{
dword i;
dword cursor_pos = lines.get(list.cur_y) + list.cur_x;
 
switch(key_scancode)
486,6 → 460,8
{
case SCAN_CODE_DOWN:
case SCAN_CODE_UP:
case SCAN_CODE_LEFT:
case SCAN_CODE_RIGHT:
case SCAN_CODE_HOME:
case SCAN_CODE_END:
case SCAN_CODE_PGUP:
492,21 → 468,45
case SCAN_CODE_PGDN:
return;
case SCAN_CODE_BS:
if (selection.is_active()) {
EventDeleteSelectedText();
} else {
if (!list.cur_x) && (!list.cur_y) break;
textbuf.del(cursor_pos-1, cursor_pos);
if (!list.cur_x) && (list.cur_y) {
list.column_max = lines.len(list.cur_y-1);
list.KeyLeft();
}
list.KeyLeft();
}
ParseAndPaint();
return;
case SCAN_CODE_DEL:
notify("'Not supported yet'A");
if (selection.is_active()) {
EventDeleteSelectedText();
} else {
if (cursor_pos < textbuf.p + textbuf.len) textbuf.del(cursor_pos, cursor_pos+1);
}
ParseAndPaint();
return;
default:
if (selection.is_active()) {
EventDeleteSelectedText();
Parse();
}
 
if (list.cur_x >= list.column_max) return;
 
ESBYTE[cursor_pos] = key_ascii;
cursor_pos = lines.get(list.cur_y) + list.cur_x;
textbuf.insert_ch(cursor_pos, key_ascii);
list.KeyRight();
PaintVisible();
Parse();
list.column_max = lines.len(list.cur_y);
if (key_scancode == SCAN_CODE_ENTER) list.KeyRight();
DrawPage();
}
}
 
void EventOpenSysfuncs()
{
if (io.run("/sys/docpack", "f") <= 0) {
if (RunProgram("/sys/docpack", "f") <= 0) {
notify("'Can not open SysFunctions because\n/rd/1/docpack is not found!'E");
}
}
513,7 → 513,7
 
void EventOpenPipet()
{
io.run("/sys/develop/pipet", NULL);
RunProgram("/sys/develop/pipet", NULL);
}
 
void EventRbmMenuClick(dword id)
527,9 → 527,10
}
}
 
void EventCut()
void EventSelectAllText()
{
//selection.copy();
selection.select_all();
DrawPage();
}
 
void EventCopy()
560,31 → 561,51
DrawStatusBar(#copy_status_text);
}
 
void EventCut()
{
if (!selection.is_active()) {
selection.start_offset = lines.get(list.cur_y);
selection.end_offset = lines.get(list.cur_y+1);
}
EventCopy();
EventDeleteSelectedText();
ParseAndPaint();
}
 
void EventPaste()
{
//selection.copy();
int i;
dword buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
if (selection.is_active()) {
EventDeleteSelectedText();
}
cursor_pos = lines.get(list.cur_y) + list.cur_x;
textbuf.insert_str(cursor_pos, buf+12, ESDWORD[buf]-12);
for (i=0; i<ESDWORD[buf]-12; i++) list.KeyRight();
ParseAndPaint();
}
 
void EventDeleteSelectedText()
{
textbuf.del(selection.start_offset, selection.end_offset);
list.cur_x = math.min(selection.start_x, selection.end_x);
list.cur_y = math.min(selection.start_y, selection.end_y);
selection.cancel();
}
 
void EventRevealInFolder()
{
RunProgram("/sys/File managers/Eolite", #param);
RunProgram("/sys/File managers/Eolite", #file_path);
}
 
void EventCopyFilePath()
{
char copy_status_text[32];
Clipboard__CopyText(#param);
sprintf(#copy_status_text, #copied_chars, strlen(#param));
Clipboard__CopyText(#file_path);
sprintf(#copy_status_text, #copied_chars, strlen(#file_path));
DrawStatusBar(#copy_status_text);
}
 
void EventEnableEdit()
{
enable_edit ^= 1;
if (enable_edit) notify("'Edit mode is enabled.\nNow you can only replace text, not insert, nor delete.'I");
draw_window();
}
 
//===================================================//
// //
// DRAWS AND OTHER FUNCS //
598,36 → 619,36
// Autodetecting charset
if (real_encoding == CH_AUTO) {
real_encoding = CH_CP866;
if (strstr(io.buffer_data, "\208\190")) real_encoding = CH_UTF8;
if (strstr(textbuf.p, "\208\190")) real_encoding = CH_UTF8;
else {
if (chrnum(io.buffer_data, '\246')>5)
|| (strstr(io.buffer_data, "\239\240")) real_encoding = CH_CP1251;
if (chrnum(textbuf.p, '\246')>5)
|| (strstr(textbuf.p, "\239\240")) real_encoding = CH_CP1251;
}
}
if (real_encoding != CH_CP866) {
ChangeCharset(real_encoding, "CP866", io.buffer_data);
ChangeCharset(real_encoding, "CP866", textbuf.p);
}
}
 
void LoadFile(dword f_path)
{
if (io.buffer_data) free(io.buffer_data);
if (ESBYTE[f_path]) {
strcpy(#param, f_path);
if (!io.read(#param)) goto NO_DATA;
sprintf(#title, "%s - %s", #param, #short_app_name);
strcpy(#file_path, f_path);
if (!io.read(#file_path)) goto NO_DATA;
textbuf.set(io.buffer_data, io.FILES_SIZE);
free(io.buffer_data);
sprintf(#title, "%s - %s", #file_path, #short_app_name);
EncodeToDos();
}
else {
NO_DATA:
io.buffer_data = malloc(sizeof(intro));
strcpy(io.buffer_data, #intro);
textbuf.set(#intro, sizeof(intro)-1);
strcpy(#title, #short_app_name);
}
list.ClearList();
}
 
int AddTopBarButton(dword _event, _hotkey, char image_id, int x, pressed) {
int TopBarBt(dword _event, _hotkey, char image_id, int x, pressed) {
if (_hotkey) key.add_n(_hotkey, _event);
return DrawTopPanelButton(button.add(_event), x, 5, image_id, pressed);
}
635,13 → 656,12
 
void DrawToolbar()
{
#define SMALL_GAP 26+5
#define BIG_GAP 26+18
#define GAP_S 26+5
#define GAP_B 26+18
incn x;
bool thema = false;
bool reopa = false;
 
bool serha = search.draw(BTN_FIND_NEXT+10, BTN_FIND_CLOSE+10, Form.cheight - SEARCH_H - STATUSBAR_H);
if (menu_id == COLOR_SCHEME) thema = true;
if (menu_id == REOPEN_IN_APP) reopa = true;
 
648,21 → 668,20
DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work);
DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.work_graph);
x.set(-SMALL_GAP+8);
if(enable_edit) AddTopBarButton(#EventNewFile, ECTRL+SCAN_CODE_KEY_N, 2, x.inc(SMALL_GAP), false);
AddTopBarButton(#EventOpenDialog, ECTRL+SCAN_CODE_KEY_O, 0, x.inc(SMALL_GAP), false);
if(enable_edit) && (param[0]) AddTopBarButton(#EventSave, ECTRL+SCAN_CODE_KEY_S, 5, x.inc(SMALL_GAP), false);
AddTopBarButton(#EventShowFileInfo, ECTRL+SCAN_CODE_KEY_I, 10, x.inc(SMALL_GAP), false);
AddTopBarButton(#EventMagnifyMinus, ECTRL+SCAN_CODE_MINUS, 33, x.inc(BIG_GAP), false);
AddTopBarButton(#EventMagnifyPlus, ECTRL+SCAN_CODE_PLUS, 32, x.inc(SMALL_GAP), false);
AddTopBarButton(#EventClickSearch, ECTRL+SCAN_CODE_KEY_F, 49, x.inc(BIG_GAP), serha); search_mx = EAX;
x.set(-GAP_S+8);
TopBarBt(#EventNewFile, ECTRL+SCAN_CODE_KEY_N, 2, x.inc(GAP_S), false);
TopBarBt(#EventOpenDialog, ECTRL+SCAN_CODE_KEY_O, 0, x.inc(GAP_S), false);
TopBarBt(#EventSave, ECTRL+SCAN_CODE_KEY_S, 5, x.inc(GAP_S), false);
TopBarBt(#EventShowFileInfo, ECTRL+SCAN_CODE_KEY_I, 10, x.inc(GAP_S), false);
TopBarBt(#EventMagnifyMinus, ECTRL+SCAN_CODE_MINUS, 33, x.inc(GAP_B), false);
TopBarBt(#EventMagnifyPlus, ECTRL+SCAN_CODE_PLUS, 32, x.inc(GAP_S), false);
TopBarBt(#EventClickSearch, ECTRL+SCAN_CODE_KEY_F, 49, x.inc(GAP_B), search.visible); search_mx = EAX;
x.set(Form.cwidth-4);
AddTopBarButton(#EventEnableEdit, NULL, 38, x.inc(-SMALL_GAP), enable_edit);
//if(enable_edit) AddTopBarButton(#EventShowInfo, NULL, -1, x.inc(-SMALL_GAP), false); burger_mx = EAX;
AddTopBarButton(#EventShowThemesList, NULL, 40, x.inc(-BIG_GAP), thema); theme_mx = EAX;
AddTopBarButton(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-SMALL_GAP), reopa); reopenin_mx = EAX;
if(enable_edit) AddTopBarButton(#EventOpenSysfuncs, NULL, 18, x.inc(-SMALL_GAP), false);
if(enable_edit) AddTopBarButton(#EventOpenPipet, NULL, 39, x.inc(-SMALL_GAP), false);
TopBarBt(#EventShowInfo, NULL, -1, x.inc(-GAP_S), false); burger_mx = EAX;
TopBarBt(#EventShowThemesList, NULL, 40, x.inc(-GAP_B), thema); theme_mx = EAX;
TopBarBt(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-GAP_S), reopa); reopenin_mx = EAX;
TopBarBt(#EventOpenSysfuncs, NULL, 18, x.inc(-GAP_S), false);
TopBarBt(#EventOpenPipet, NULL, 39, x.inc(-GAP_S), false);
}
 
void DrawStatusBar(dword _in_text)
673,7 → 692,7
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
WriteText(5, Form.cheight - STATUSBAR_H + 4, 0x80, sc.work_text, #status_text);
if (param[0]) {
if (file_path[0]) {
WriteTextCenter(Form.cwidth-70, Form.cheight - STATUSBAR_H + 4,
60, sc.work_text, real_encoding*10+#charsets);
DefineHiddenButton(Form.cwidth-70, Form.cheight - STATUSBAR_H + 1,
684,6 → 703,7
void draw_window()
{
int old_w = list.w;
if (CheckActiveProcess(Form.ID)) EventMenuClick();
DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
GetProcessInfo(#Form, SelfInfo);
sc.get();
694,7 → 714,7
button.init(40);
key.init(40);
 
SetSizes(font_size);
SetFontSize(font_size);
 
if ((list.w == old_w) && (list.count)) {
DrawPage();
703,31 → 723,47
}
 
DrawToolbar();
DrawSearch();
DrawStatusBar(NULL);
}
 
void DrawPage()
bool DrawSearch()
{
scroll.max_area = list.count;
scroll.cur_area = list.visible;
scroll.position = list.first;
scroll.all_redraw = 0;
scroll.start_x = list.x + list.w;
scroll.start_y = list.y;
scroll.size_y = list.h;
scrollbar_v_draw(#scroll);
char matches[30];
int _y = Form.cheight - SEARCH_H - STATUSBAR_H;
if (!search.visible) return false;
DrawBar(0, _y, Form.cwidth, 1, sc.work_graph);
DrawBar(0, _y+1, Form.cwidth, SEARCH_H-1, sc.work);
 
DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x,
scroll.size_y-1, scroll.bckg_col);
PaintVisible();
search_box.top = _y + 6;
search_box.width = math.min(Form.width - 200, 150);
 
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, 30,
TOOLBAR_ICON_HEIGHT+1, BTN_FIND_PREVIOUS+10, sc.work_light, sc.work_text, "<");
DrawCaptButton(search_box.left+search_box.width+44, search_box.top-1, 30,
TOOLBAR_ICON_HEIGHT+1, BTN_FIND_NEXT+10, sc.work_light, sc.work_text, ">");
 
sprintf(#matches, T_MATCHES, search.found.count);
WriteTextWithBg(search_box.left+search_box.width+14+85,
search_box.top+3, 0xD0, sc.work_text, #matches, sc.work);
 
DefineHiddenButton(Form.cwidth-26, search_box.top-1, TOOLBAR_ICON_HEIGHT+1,
TOOLBAR_ICON_HEIGHT+1, BTN_FIND_CLOSE+10);
WriteText(Form.cwidth-26+7, search_box.top+2, 0x81, sc.work_graph, "x");
return true;
}
 
 
void SetSizes(char _size)
void SetFontSize(char _size)
{
font_size = _size;
if (font_size == 'S') list.SetFont(6, 9, 00001000b);
if (font_size == 'M') list.SetFont(8, 14, 00011000b);
if (font_size == 0) list.SetFont( 6, 9, 00001000b);
if (font_size == 1) list.SetFont( 8, 14, 00011000b);
if (font_size == 2) list.SetFont(2*6, 2*9, 00001001b);
if (font_size == 3) list.SetFont(2*8, 2*14-2, 00011001b);
list.item_w = list.font_w;
list.horisontal_selelection = true;
list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1,
/programs/cmm/quark/search.h
9,11 → 9,11
collection_int found;
void show();
void hide();
bool draw();
bool edit_key();
bool edit_mouse();
int find_all();
int find_next();
int find_prior();
} search;
 
char found_text[64];
55,36 → 55,9
return false;
}
 
bool SEARCH::draw(dword _btn_find, _btn_hide, _y)
{
char matches[30];
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, 150);
 
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, 100,
TOOLBAR_ICON_HEIGHT+1, _btn_find, sc.work_light, sc.work_text, T_FIND_NEXT);
 
sprintf(#matches, T_MATCHES, found.count);
WriteTextWithBg(search_box.left+search_box.width+14+115,
search_box.top+3, 0xD0, sc.work_text, #matches, sc.work);
 
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;
}
 
int SEARCH::find_all()
{
dword haystack = io.buffer_data;
dword haystack = textbuf.p;
int needle_len = strlen(#found_text);
found.drop();
loop() {
94,10 → 67,9
}
}
 
int SEARCH::find_next(int _cur_pos)
int SEARCH::find_next(int _first)
{
int i;
dword t1, t2;
if (!search_text[0]) return false;
 
if (!streq(#found_text, #search_text)) {
107,12 → 79,30
}
 
for (i=0; i<found.count; i++) {
if (signed found.get(i) - lines.get(_cur_pos) > 0) {
t1 = found.get(i);
while(t1 > lines.get(_cur_pos)) _cur_pos++;
return _cur_pos-1;
if (signed found.get(i) - lines.get(_first) > 0) {
while(signed found.get(i) - lines.get(_first) > 0) _first++;
return _first-1;
}
}
return false;
}
 
int SEARCH::find_prior(int _first)
{
int i;
if (!search_text[0]) return false;
 
if (!streq(#found_text, #search_text)) {
strcpy(#found_text, #search_text);
find_all();
draw_window();
}
 
for (i=0; i<found.count; i++) {
if (signed found.get(i) - lines.get(_first) > 0) {
while(signed lines.get(_first) - found.get(i-1) > 0) _first--;
return _first;
}
}
return false;
}
/programs/cmm/quark/textbuf.h
0,0 → 1,58
struct TEXTBUF
{
dword p;
unsigned len;
unsigned max;
void drop();
void extend();
void set();
void insert_ch();
void insert_str();
void del();
} textbuf;
 
void TEXTBUF::drop()
{
p = free(p);
len = max = 0;
}
 
void TEXTBUF::extend(unsigned _size)
{
max = _size;
p = realloc(p, max);
}
 
void TEXTBUF::set(dword _p, unsigned _size)
{
len = _size;
extend(len + 4096);
strncpy(p, _p, len);
}
 
void TEXTBUF::insert_ch(unsigned _pos, char _ch)
{
char str[1];
str[0] = _ch;
insert_str(_pos, #str, 1);
}
 
void TEXTBUF::insert_str(unsigned _pos, dword _string, unsigned _sl)
{
dword i;
if (len + _sl >= max) {
extend(len + _sl + 4096);
}
len += _sl;
for (i=p+len; i>=_pos+_sl; i--) {
ESBYTE[i] = ESBYTE[i-_sl];
}
memmov(_pos, _string, _sl);
}
 
void TEXTBUF::del(unsigned _start, _end)
{
if (_start > _end) _end >< _start;
strcpy(_start, _end);
len -= _end - _start;
}