From 804cb0b51cbb5a22069b6b7cdbaf4c91044d078b Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Thu, 24 Jun 2021 20:42:19 +0000 Subject: [PATCH] clipview: rewrite and decrease the size twice (from 3847 bytes to 1958) search: new app, alpha version git-svn-id: svn://kolibrios.org@8933 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/appearance/appearance.c | 3 +- programs/cmm/clipview/build.bat | 5 + programs/cmm/clipview/clipview.c | 212 ++++++++----- programs/cmm/clipview/compile_en.bat | 9 - programs/cmm/drvinst/drvinst.c | 6 +- programs/cmm/eolite/include/copy_and_delete.h | 2 +- programs/cmm/eolite/include/settings.h | 2 +- programs/cmm/lib/patterns/select_list.h | 8 +- programs/cmm/search/Tupfile.lua | 6 + programs/cmm/search/build_en.bat | 10 + programs/cmm/search/build_ru.bat | 10 + programs/cmm/search/search.c | 296 ++++++++++++++++++ programs/cmm/sysmon/sysmon.c | 2 +- 13 files changed, 465 insertions(+), 106 deletions(-) create mode 100644 programs/cmm/clipview/build.bat delete mode 100644 programs/cmm/clipview/compile_en.bat create mode 100644 programs/cmm/search/Tupfile.lua create mode 100644 programs/cmm/search/build_en.bat create mode 100644 programs/cmm/search/build_ru.bat create mode 100644 programs/cmm/search/search.c diff --git a/programs/cmm/appearance/appearance.c b/programs/cmm/appearance/appearance.c index 2b1d7ec95d..b6f60c5df2 100644 --- a/programs/cmm/appearance/appearance.c +++ b/programs/cmm/appearance/appearance.c @@ -208,8 +208,7 @@ void DrawWindowContent() tabs.x+TAB_PADDING, tabs.y+TAB_HEIGHT+TAB_PADDING, list_w, - Form.cheight-LP-LP - TAB_PADDING - TAB_PADDING - TAB_HEIGHT, - false + Form.cheight-LP-LP - TAB_PADDING - TAB_PADDING - TAB_HEIGHT ); select_list.cur_y = id; diff --git a/programs/cmm/clipview/build.bat b/programs/cmm/clipview/build.bat new file mode 100644 index 0000000000..336b436bb7 --- /dev/null +++ b/programs/cmm/clipview/build.bat @@ -0,0 +1,5 @@ +@del clipview +@c-- /D=LANG_ENG clipview.c +@rename clipview.com clipview +@del warning.txt +@pause \ No newline at end of file diff --git a/programs/cmm/clipview/clipview.c b/programs/cmm/clipview/clipview.c index 7f6654b096..36fba12411 100644 --- a/programs/cmm/clipview/clipview.c +++ b/programs/cmm/clipview/clipview.c @@ -1,17 +1,11 @@ -#ifndef AUTOBUILD - ?include "lang.h--" -#endif +#define ENTRY_POINT #main #define MEMSIZE 4096*20 -#include "..\lib\mem.h" + #include "..\lib\strings.h" -#include "..\lib\list_box.h" #include "..\lib\clipboard.h" #include "..\lib\gui.h" -#include "..\lib\obj\box_lib.h" - -#include "..\lib\patterns\select_list.h" - +#include "..\lib\fs.h" //===================================================// // // @@ -19,28 +13,35 @@ // // //===================================================// -?define WINDOW_HEADER "Clipboard Viewer" -?define T_DELETE_LAST_SLOT "Delete last slot" -?define T_DELETE_ALL_SLOTS "Delete all slots" -?define T_RESET_BUFFER_LOCK "Reset the lock buffer" ?define T_COLUMNS_TITLE "# | Data size | Data type | Contents" ?define T_COLUMN_VIEW "| View" -?define T_VIEW_OPTIONS "TEXT HEX" ?define DEFAULT_SAVE_PATH "/tmp0/1/clipview.tmp" char *data_type[] = { "Text", "Image", "RAW", "Unknown" }; enum { - BT_DELETE_LAST_SLOT = 10, - BT_DELETE_ALL_SLOTS, - BT_UNLOCK + BT_DELETE_LAST = 10, + BT_DELETE_ALL, + BT_UNLOCK, + BT_LIST_LEFT, + BT_LIST_RIGHT }; -#define PANEL_TOP_H 20 -#define PANEL_BOTTOM_H 30 -#define LIST_PADDING 12 +#define PANEL_BOTTOM_H 35 +#define GAP 5 +#define LIST_Y 32 +#define PANEL_TOP_H LIST_Y-2 +#define LINE_H 20 +#define TEXT_Y LINE_H - 14 / 2 proc_info Form; +struct LIST { + int w,h; + int count; + int first; + int visible; +} list = 0; + //===================================================// // // // CODE // @@ -49,66 +50,77 @@ proc_info Form; void main() { - int id; - @SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); - #define NO_DLL_INIT - load_dll(boxlib, #box_lib_init,0); + mem_init(); + @SetEventMask(EVM_REDRAW + EVM_BUTTON); loop() switch(@WaitEventTimeout(10)) { - case evMouse: - SelectList_ProcessMouse(); - break; - case evButton: - id = @GetButtonID(); - if (id==1) ExitProcess(); - if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot(); - if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots(); - if (id==BT_UNLOCK) EventResetBufferLock(); - if (id>=100) && (id<300) EventOpenAsText(id-100); - if (id>=300) EventOpenAsHex(id-300); - break; - - case evKey: - if (select_list.ProcessKey(@GetKeyScancode())) { - ClipViewSelectListDraw(); + @GetButtonID(); + switch(EAX) { + case 1: + ExitProcess(); + case BT_DELETE_LAST: + EventDeleteLastSlot(); + break; + case BT_DELETE_ALL: + EventDeleteAllSlots(); + break; + case BT_UNLOCK: + EventResetBufferLock(); + break; + case BT_LIST_LEFT: + list.first -= list.visible; + if (list.first <= 0) list.first = 0; + ClipViewSelectListDraw(); + break; + case BT_LIST_RIGHT: + if (list.first + list.visible < list.count) list.first += list.visible; + ClipViewSelectListDraw(); + break; + default: + if (EAX>=300) EventOpenAsHex(EAX-300); + else EventOpenAsText(EAX-100); } break; case evReDraw: sc.get(); - DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); + DefineAndDrawWindow(GetScreenWidth()-600/2,80,600,400,0x73,NULL,"Clipboard Viewer",NULL); GetProcessInfo(#Form, SelfInfo); IF (Form.status_window>=2) break; IF (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } IF (Form.width < 570) { MoveSize(OLD,OLD,570,OLD); break; } - SelectList_Init( - LIST_PADDING, - LIST_PADDING+PANEL_TOP_H, - Form.cwidth-LIST_PADDING-LIST_PADDING-scroll1.size_x, - Form.cheight-PANEL_BOTTOM_H-PANEL_TOP_H-LIST_PADDING-LIST_PADDING, - true - ); DrawWindowContent(); break; default: - if (Clipboard__GetSlotCount() > select_list.count) ClipViewSelectListDraw(); - break; + if (Clipboard__GetSlotCount() > list.count) ClipViewSelectListDraw(); } } void DrawWindowContent() { - int button_x = select_list.x; + list.w = Form.cwidth-GAP-GAP; + list.h = Form.cheight-PANEL_BOTTOM_H-LIST_Y-GAP; + list.visible = list.h / LINE_H; + if (list.first > list.count) list.first = list.count - list.visible; + DrawBar(0,0, Form.cwidth, PANEL_TOP_H, sc.work); DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, sc.work); - DrawWideRectangle(select_list.x-LIST_PADDING, select_list.y-LIST_PADDING, LIST_PADDING*2+select_list.w+scroll1.size_x, LIST_PADDING*2+select_list.h, LIST_PADDING-2, sc.work); - button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_LAST_SLOT, T_DELETE_LAST_SLOT); - button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_ALL_SLOTS, T_DELETE_ALL_SLOTS); - button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_UNLOCK, T_RESET_BUFFER_LOCK); - WriteText(select_list.x+12, select_list.y - 23, 0x90, sc.work_text, T_COLUMNS_TITLE); - WriteText(select_list.x+select_list.w - 88-14, select_list.y - 23, 0x90, sc.work_text, T_COLUMN_VIEW); + DrawWideRectangle(GAP-GAP, LIST_Y-GAP, GAP*2+list.w, GAP*2+list.h, GAP-2, sc.work); + + DefineButton(GAP, list.h + LIST_Y + 8, 110, 25, BT_DELETE_LAST, sc.button); + $inc edx + $add ebx, 130 << 16 //BT_DELETE_ALL + $int 64 + $inc edx + $add ebx, 130 << 16 //BT_UNLOCK + $int 64 + + WriteText(GAP+10, LIST_Y + list.h + 14, 0x90, sc.button_text, "Delete last Delete all Unlock"); + + WriteText(GAP+12, LIST_Y - 23, 0x90, sc.work_text, T_COLUMNS_TITLE); + WriteText(GAP+list.w - 88-14, LIST_Y - 23, 0x90, sc.work_text, T_COLUMN_VIEW); ClipViewSelectListDraw(); SelectList_DrawBorder(); } @@ -125,10 +137,16 @@ struct clipboard_data void SelectList_DrawLine(dword i) { - int yyy, length, slot_data_type_number; - dword line_text[2048]; + int yyy, slot_data_type_number; - slot_data = Clipboard__GetSlotData(select_list.first + i); + yyy = i*LINE_H+LIST_Y; + DrawBar(GAP, yyy, list.w, LINE_H, -i%2 * 0x0E0E0E + 0xF1F1f1); + + if (list.first + i >= list.count) { + return; + } + + slot_data = Clipboard__GetSlotData(list.first + i); cdata.size = ESDWORD[slot_data]; cdata.type = ESDWORD[slot_data+4]; if (cdata.type==SLOT_DATA_TYPE_TEXT) || (cdata.type==SLOT_DATA_TYPE_TEXT_BLOCK) @@ -137,22 +155,18 @@ void SelectList_DrawLine(dword i) cdata.content_offset = 8; cdata.content = slot_data + cdata.content_offset; - yyy = i*select_list.item_h+select_list.y; - DrawBar(select_list.x+1, yyy, select_list.w-1, select_list.item_h, -i%2 * 0x0E0E0E + 0xF1F1f1); - WriteText(select_list.x+12, yyy+select_list.text_y, 0x90, 0x000000, itoa(select_list.first + i)); + WriteText(GAP+12, yyy+TEXT_Y, 0x90, 0x000000, itoa(list.first + i)); EDX = ConvertSizeToKb(cdata.size); - WriteText(select_list.x+44, yyy+select_list.text_y, 0x90, 0x000000, EDX); + WriteText(GAP+44, yyy+TEXT_Y, 0x90, 0x000000, EDX); slot_data_type_number = cdata.type; - WriteText(select_list.x+140, yyy+select_list.text_y, 0x90, 0x000000, data_type[slot_data_type_number]); - WriteText(select_list.x+select_list.w - 88, yyy+select_list.text_y, 0x90, 0x006597, T_VIEW_OPTIONS); - DefineButton(select_list.x+select_list.w - 95, yyy, 50, select_list.item_h, 100+i+BT_HIDE, NULL); - DefineButton(select_list.x+select_list.w - 95 + 51, yyy, 40, select_list.item_h, 300+i+BT_HIDE, NULL); + WriteText(GAP+140, yyy+TEXT_Y, 0x90, 0x000000, data_type[slot_data_type_number]); + WriteText(GAP+list.w - 88, yyy+TEXT_Y, 0x90, 0x006597, "TEXT HEX"); + DefineButton(GAP+list.w - 98, yyy, 50, LINE_H, 100+i+BT_HIDE, NULL); + DefineButton(GAP+list.w - 95 + 51, yyy, 40, LINE_H, 300+i+BT_HIDE, NULL); - length = select_list.w-236 - 95 / select_list.font_w - 2; - if (cdata.size - cdata.content_offset < length) length = cdata.size - cdata.content_offset; - strlcpy(#line_text, cdata.content, length); - replace_char(#line_text, 0, 31, length); // 31 is a dot - WriteText(select_list.x+236, yyy+select_list.text_y, 0x90, 0x000000, #line_text); + ESI = list.w - 345 / 8; + if (cdata.size - cdata.content_offset < ESI) ESI = cdata.size - cdata.content_offset; + WriteText(GAP+236, yyy+TEXT_Y, 0x30, 0x000000, cdata.content); } int SaveSlotContents(dword size, off) { @@ -164,13 +178,42 @@ int SaveSlotContents(dword size, off) { } } -void ClipViewSelectListDraw() { - select_list.count = Clipboard__GetSlotCount(); - SelectList_Draw(); +void ClipViewSelectListDraw() +{ + int i, list_last; + + list.count = Clipboard__GetSlotCount(); + + if (list.count > list.visible) list_last = list.visible; else list_last = list.count; + + for (i=0; i list.visible) { + param[0] = list.first / list.visible + '0'; + DefineButton(Form.cwidth-84-GAP, list.h + LIST_Y + 8, 25, 25, BT_LIST_LEFT, sc.button); //BT_LEFT + $inc edx + $add ebx, 57 << 16 //BT_RIGHT + $int 64 + WriteText(Form.cwidth-84-GAP+10, list.h + LIST_Y + 14, 0x90, sc.button_text, "< >"); + $add ebx, 28 << 16 + $mov edx, #param; + $mov edi, sc.work_text + $add ecx, 0x40 << 24 + $int 64 + } } -void SelectList_LineChanged() { - return; +void SelectList_DrawBorder() { + DrawRectangle3D(GAP-2, LIST_Y-2, + list.w+3, list.h+3, + sc.work_dark, sc.work_light); + DrawRectangle3D(GAP-1, LIST_Y-1, + list.w+1, list.h+1, + sc.work_graph, sc.work_graph); } //===================================================// @@ -182,21 +225,24 @@ void SelectList_LineChanged() { void EventDeleteLastSlot() { int i; - for (i=0; ilang.h-- - -@C-- clipview.c -@del clipview -@rename clipview.com clipview -@del warning.txt -@del lang.h-- -@pause \ No newline at end of file diff --git a/programs/cmm/drvinst/drvinst.c b/programs/cmm/drvinst/drvinst.c index f0f4f5d4e3..1a32b2ae66 100644 --- a/programs/cmm/drvinst/drvinst.c +++ b/programs/cmm/drvinst/drvinst.c @@ -141,11 +141,9 @@ void Draw_DriverListWindow() int right_frame_x = Form.cwidth*46/100; int readme_w = 0; //LEFT FRAME - SelectList_Init(PADDING, - PADDING, + SelectList_Init(PADDING, PADDING, right_frame_x - PADDING - PADDING - 8 - scroll1.size_x, - Form.cheight - PADDING - PADDING, - false); + Form.cheight - PADDING - PADDING); SelectList_Draw(); SelectList_DrawBorder(); //RIGHT FRAME diff --git a/programs/cmm/eolite/include/copy_and_delete.h b/programs/cmm/eolite/include/copy_and_delete.h index e96675698b..fd7d3ee0f1 100644 --- a/programs/cmm/eolite/include/copy_and_delete.h +++ b/programs/cmm/eolite/include/copy_and_delete.h @@ -89,7 +89,7 @@ void CopyFilesListToClipboard(bool _cut_active) if (cut_active) { if (i>=files.first) && (i=2) return; + if (Form.width < 270) { MoveSize(OLD,OLD,270,OLD); return; } + if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } + SelectList_Init( 0, TOOLBAR_H, + Form.cwidth-scroll1.size_x-1, + Form.cheight-TOOLBAR_H-1); + SelectList_Draw(); + DrawBar(0, TOOLBAR_H-1, Form.cwidth, 1, sc.work_graph); + DrawBar(0, 0, Form.cwidth, TOOLBAR_H-1, sc.work); + DrawEditBox(#edit_name); + WriteText(edit_name.left-2, edit_name.top-20, 0x90, sc.work_text, T_SEARCH_NAME); + edit_path.width = Form.cwidth - 314; + DrawFileBox(#edit_path, T_SEARCH_PATH, BTN_CHOOSE_PATH); + DrawStandartCaptButton(10, 63, BTN_SEARCH, T_BUTTON_SEARCH); +} + +_ini ini = { "/sys/File managers/icons.ini", "icons16" }; +void SelectList_DrawLine(dword i) +{ + int yyy = i*select_list.item_h+select_list.y; + dword bg = 0xFFFfff; + dword col = 0; + int icon; + char tname[4096]; + + if (!select_list.count) return; + + if (select_list.cur_y-select_list.first==i) + { + bg = sc.button; + col = sc.button_text; + if (edit_name.flags & ed_focus) || (edit_path.flags & ed_focus) bg = 0xAAAaaa; + } + + if (results.type.get(select_list.first + i)==true) { + icon=0; + } else { + strcpy(#tname, results.name.get(select_list.first + i)); + strlwr(#tname); + icon = ini.GetInt(#tname + strrchr(#tname, '.'), 2); + } + + #define ICONX 7 + DrawBar(select_list.x, yyy, ICONX-1, select_list.item_h, 0xFFFfff); + DrawBar(select_list.x+ICONX+18, yyy, select_list.w-ICONX-18, select_list.item_h, bg); + DrawIcon16(select_list.x+ICONX, yyy+1, 0xFFFfff, icon); + + WriteText(select_list.x + ICONX+18+4,yyy+select_list.text_y,0x90, col, results.name.get(select_list.first + i)); + WriteText(select_list.x + ICONX+18+206,yyy+select_list.text_y,0x90, col, results.path.get(select_list.first + i)); +} + +void SelectList_LineChanged() +{ + return; +} + +//===================================================// +// // +// EVENTS // +// // +//===================================================// + +void EventChooseSearchInPath() +{ + OpenDialog_start stdcall (#open_folder_dialog); + if (open_folder_dialog.status) { + edit_box_set_text stdcall (#edit_path, #search_path); + } +} + +void getfullpath(dword to, path, name) { + strcpy(to, path); + chrcat(to, '/'); + strcat(to, name); +} + +void EventOpenFile(int run_file_not_show_in_folder) +{ + char full_path[4096]; + int pos = select_list.cur_y; + getfullpath(#full_path, results.path.get(pos), results.name.get(pos)); + if (run_file_not_show_in_folder) { + RunProgram("/sys/@open", #full_path); + } else { + RunProgram("/sys/file managers/eolite", #full_path); + } +} + +void EventSearch() +{ + results.drop(); + find_loop(#search_path); + select_list.count = results.count; + SelectList_Draw(); +} + +void find_loop(dword way) +{ + dword dirbuf, fcount, i, filename; + dword cur_file; + bool folder; + + if (way) && (dir_exists(way)) + { + cur_file = malloc(4096); + // In the process of recursive descent, memory must be allocated dynamically, + // because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed. + GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL); + for (i=0; i