forked from KolibriOS/kolibrios
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
This commit is contained in:
parent
1aa78952d7
commit
804cb0b51c
@ -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;
|
||||
|
||||
|
5
programs/cmm/clipview/build.bat
Normal file
5
programs/cmm/clipview/build.bat
Normal file
@ -0,0 +1,5 @@
|
||||
@del clipview
|
||||
@c-- /D=LANG_ENG clipview.c
|
||||
@rename clipview.com clipview
|
||||
@del warning.txt
|
||||
@pause
|
@ -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);
|
||||
@GetButtonID();
|
||||
switch(EAX) {
|
||||
case 1:
|
||||
ExitProcess();
|
||||
case BT_DELETE_LAST:
|
||||
EventDeleteLastSlot();
|
||||
break;
|
||||
|
||||
case evKey:
|
||||
if (select_list.ProcessKey(@GetKeyScancode())) {
|
||||
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_last; i++;) SelectList_DrawLine(i);
|
||||
|
||||
DrawBar(GAP,i*LINE_H+LIST_Y, list.w, -i*LINE_H+ list.h, 0xFFFfff);
|
||||
if (!list.count) WriteText(list.w / 2 + GAP - 60,
|
||||
list.h / 2 - 8 + LIST_Y, 0x90, 0x999999, "No data to show");
|
||||
|
||||
if (list.count > 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; i<select_list.visible; i++;) DeleteButton(select_list.first + i + 100);
|
||||
for (i=0; i<select_list.visible; i++;) DeleteButton(select_list.first + i + 300);
|
||||
for (i=0; i<list.visible; i++;) {
|
||||
DeleteButton(list.first + i + 100);
|
||||
$add edx, 200
|
||||
$int 64
|
||||
}
|
||||
Clipboard__DeleteLastSlot();
|
||||
ClipViewSelectListDraw();
|
||||
DrawWindowContent();
|
||||
}
|
||||
|
||||
void EventDeleteAllSlots()
|
||||
{
|
||||
while (Clipboard__GetSlotCount()) Clipboard__DeleteLastSlot();
|
||||
ClipViewSelectListDraw();
|
||||
DrawWindowContent();
|
||||
}
|
||||
|
||||
void EventResetBufferLock() {
|
||||
Clipboard__ResetBlockingBuffer();
|
||||
ClipViewSelectListDraw();
|
||||
DrawWindowContent();
|
||||
}
|
||||
|
||||
void EventOpenAsText(int slot_id) {
|
||||
|
@ -1,9 +0,0 @@
|
||||
@del lang.h--
|
||||
@echo #define LANG_ENG 1 >lang.h--
|
||||
|
||||
@C-- clipview.c
|
||||
@del clipview
|
||||
@rename clipview.com clipview
|
||||
@del warning.txt
|
||||
@del lang.h--
|
||||
@pause
|
@ -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
|
||||
|
@ -89,7 +89,7 @@ void CopyFilesListToClipboard(bool _cut_active)
|
||||
|
||||
if (cut_active) {
|
||||
if (i>=files.first) && (i<files.first+files.visible)
|
||||
PutShadow(files.x+4,i-files.first*files.item_h+files.y,16,files.item_h,1,-3);
|
||||
PutShadow(files.x+4,i-files.first*files.item_h+files.y,icons16_default,files.item_h,1,-3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ void LoadIniSettings()
|
||||
ini.path = GetIni(#eolite_ini_path, "app.ini");
|
||||
if (efm) ini.section = "EFM"; else ini.section = "Eolite";
|
||||
|
||||
files.SetFont(6, 9, 10000000b);
|
||||
files.SetFont(8, 14, 10000000b);
|
||||
show_dev_name.checked = ini.GetInt("ShowDeviceName", true);
|
||||
show_status_bar.checked = ini.GetInt("ShowStatusBar", true);
|
||||
big_icons.checked = ini.GetInt("BigIcons", false); BigIconsSwitch();
|
||||
|
@ -3,9 +3,8 @@ scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0
|
||||
|
||||
?define T_SELECT_LIST_NO_DATA "No data to show"
|
||||
|
||||
void SelectList_Init(dword _x, _y, _w, _h, _no_selection)
|
||||
void SelectList_Init(dword _x, _y, _w, _h)
|
||||
{
|
||||
select_list.no_selection = _no_selection;
|
||||
select_list.SetFont(8, 14, 0x90);
|
||||
select_list.SetSizes(_x, _y, _w, _h, 20);
|
||||
}
|
||||
@ -20,12 +19,11 @@ void SelectList_Draw()
|
||||
|
||||
for (i=0; i<list_last; i++;)
|
||||
{
|
||||
DrawBar(select_list.x,i*select_list.item_h+select_list.y,select_list.w, select_list.item_h, 0xFFFfff);
|
||||
SelectList_DrawLine(i); //NEED TO BE IMPLEMENTED IN APP
|
||||
}
|
||||
DrawBar(select_list.x,i*select_list.item_h+select_list.y, select_list.w, -i*select_list.item_h+ select_list.h, 0xFFFfff);
|
||||
if (!select_list.count) WriteText(-strlen(T_SELECT_LIST_NO_DATA)*select_list.font_w + select_list.w / 2 + select_list.x + 1,
|
||||
select_list.h / 2 - 8 + select_list.y, select_list.font_type, 0x999999, T_SELECT_LIST_NO_DATA);
|
||||
if (!select_list.count) WriteText(-15*8 + select_list.w / 2 + select_list.x + 1,
|
||||
select_list.h / 2 - 8 + select_list.y, 0x90, 0x999999, T_SELECT_LIST_NO_DATA);
|
||||
SelectList_DrawScroller();
|
||||
}
|
||||
|
||||
|
6
programs/cmm/search/Tupfile.lua
Normal file
6
programs/cmm/search/Tupfile.lua
Normal file
@ -0,0 +1,6 @@
|
||||
if tup.getconfig("NO_CMM") ~= "" then return end
|
||||
if tup.getconfig("LANG") == "ru"
|
||||
then C_LANG = "LANG_RUS"
|
||||
else C_LANG = "LANG_ENG" -- this includes default case without config
|
||||
end
|
||||
tup.rule("search.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "search.com")
|
10
programs/cmm/search/build_en.bat
Normal file
10
programs/cmm/search/build_en.bat
Normal file
@ -0,0 +1,10 @@
|
||||
@del search
|
||||
@c-- /D=LANG_ENG search.c
|
||||
@rename search.com search
|
||||
@del warning.txt
|
||||
|
||||
if exist search (
|
||||
@exit
|
||||
) else (
|
||||
@pause
|
||||
)
|
10
programs/cmm/search/build_ru.bat
Normal file
10
programs/cmm/search/build_ru.bat
Normal file
@ -0,0 +1,10 @@
|
||||
@del search
|
||||
@c-- /D=LANG_RUS search.c
|
||||
@rename search.com search
|
||||
@del warning.txt
|
||||
|
||||
if exist search (
|
||||
@exit
|
||||
) else (
|
||||
@pause
|
||||
)
|
296
programs/cmm/search/search.c
Normal file
296
programs/cmm/search/search.c
Normal file
@ -0,0 +1,296 @@
|
||||
#define MEMSIZE 100*1000
|
||||
|
||||
#include "../lib/fs.h"
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/list_box.h"
|
||||
#include "../lib/obj/box_lib.h"
|
||||
#include "../lib/obj/proc_lib.h"
|
||||
#include "../lib/obj/libimg.h"
|
||||
#include "../lib/obj/libini.h"
|
||||
#include "../lib/patterns/select_list.h"
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// DATA //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
#ifdef LANG_RUS
|
||||
?define T_WINDOW_HEADER "<EFBFBD>®¨áª"
|
||||
?define T_BUTTON_SEARCH "<EFBFBD> ©â¨"
|
||||
?define T_SEARCH_PATH "Š â «®£ ¯®¨áª :"
|
||||
?define T_SEARCH_NAME "ˆ¬ï ä ©« :"
|
||||
#else
|
||||
?define T_WINDOW_HEADER "Search"
|
||||
?define T_BUTTON_SEARCH "Search"
|
||||
?define T_SEARCH_PATH "Search in:"
|
||||
?define T_SEARCH_NAME "File name:"
|
||||
#endif
|
||||
|
||||
char search_name[64];
|
||||
char search_path[4096];
|
||||
|
||||
enum {
|
||||
BTN_SEARCH = 10,
|
||||
BTN_CHOOSE_PATH
|
||||
};
|
||||
|
||||
proc_info Form;
|
||||
#define TOOLBAR_H 100
|
||||
|
||||
edit_box edit_name = {230,13, 30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(search_name)-2,#search_name,0, ed_focus,0,0};
|
||||
edit_box edit_path = {310,260,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(search_path)-2,#search_path,0, 0b,0,0};
|
||||
|
||||
opendialog open_folder_dialog =
|
||||
{
|
||||
2, //0-file, 2-save, 3-select folder
|
||||
#Form,
|
||||
#communication_area_name,
|
||||
0,
|
||||
0, //dword opendir_path,
|
||||
#search_path, //dword dir_default_path,
|
||||
#open_dialog_path,
|
||||
#draw_window,
|
||||
0,
|
||||
#search_path, //dword openfile_path,
|
||||
0, //dword filename_area,
|
||||
0, //dword filter_area,
|
||||
420,
|
||||
NULL,
|
||||
320,
|
||||
NULL
|
||||
};
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// RESULTS //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
struct RESULTS {
|
||||
collection name;
|
||||
collection path;
|
||||
collection_int type;
|
||||
unsigned count;
|
||||
void add();
|
||||
void drop();
|
||||
} results;
|
||||
|
||||
void RESULTS::add(dword _name, _path, _type)
|
||||
{
|
||||
name.add(_name);
|
||||
path.add(_path);
|
||||
type.add(_type);
|
||||
count++;
|
||||
}
|
||||
|
||||
void RESULTS::drop()
|
||||
{
|
||||
name.drop();
|
||||
path.drop();
|
||||
type.drop();
|
||||
count = 0;
|
||||
}
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// CODE //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
void main()
|
||||
{
|
||||
int prev_first, prev_cur_y;
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
load_dll(libimg, #libimg_init,1);
|
||||
load_dll(libini, #lib_init,1);
|
||||
load_dll(Proc_lib, #OpenDialog_init,0);
|
||||
OpenDialog_init stdcall (#open_folder_dialog);
|
||||
|
||||
edit_box_set_text stdcall (#edit_name, ".ini");
|
||||
edit_box_set_text stdcall (#edit_path, "/kolibrios");
|
||||
|
||||
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
||||
loop() switch(@WaitEvent())
|
||||
{
|
||||
case evMouse:
|
||||
edit_box_mouse stdcall (#edit_name);
|
||||
edit_box_mouse stdcall (#edit_path);
|
||||
if (SelectList_ProcessMouse()) {
|
||||
SelectList_Draw();
|
||||
} else {
|
||||
SelectList_DrawLine(select_list.cur_y);
|
||||
}
|
||||
if (mouse.key&MOUSE_RIGHT) && (mouse.up) && (select_list.MouseOver()) EventOpenFile(false);
|
||||
break;
|
||||
|
||||
case evButton:
|
||||
switch (@GetButtonID()) {
|
||||
case 1: @ExitProcess(); break;
|
||||
case BTN_SEARCH: EventSearch(); break;
|
||||
case BTN_CHOOSE_PATH: EventChooseSearchInPath();
|
||||
}
|
||||
break;
|
||||
|
||||
case evKey:
|
||||
@GetKeys();
|
||||
edit_box_key stdcall (#edit_name);
|
||||
edit_box_key stdcall (#edit_path);
|
||||
if (edit_name.flags & ed_focus) || (edit_path.flags & ed_focus) {
|
||||
if (SCAN_CODE_ENTER == key_scancode) EventSearch();
|
||||
} else {
|
||||
if (SCAN_CODE_ENTER == key_scancode) EventOpenFile(true);
|
||||
prev_first = select_list.first;
|
||||
prev_cur_y = select_list.cur_y;
|
||||
if (select_list.ProcessKey(key_scancode)) {
|
||||
if (prev_first == select_list.first) {
|
||||
SelectList_DrawLine(prev_cur_y);
|
||||
SelectList_DrawLine(select_list.cur_y);
|
||||
} else {
|
||||
SelectList_Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
draw_window();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void draw_window()
|
||||
{
|
||||
sc.get();
|
||||
DefineAndDrawWindow(screen.width-600/2,100,640,600+skin_height,0x73,sc.work,T_WINDOW_HEADER,0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
IF (Form.status_window>=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<fcount; i++)
|
||||
{
|
||||
filename = i*304+dirbuf+72;
|
||||
getfullpath(cur_file,way,filename);
|
||||
if (TestBit(ESDWORD[filename-40], 4) ) folder = true; else folder = false;
|
||||
|
||||
if (strstri(filename, #search_name)) {
|
||||
results.add(filename, way, folder);
|
||||
}
|
||||
|
||||
if (folder) {
|
||||
find_loop(cur_file);
|
||||
}
|
||||
}
|
||||
free(cur_file);
|
||||
free(dirbuf);
|
||||
}
|
||||
}
|
||||
|
||||
stop:
|
||||
|
||||
|
@ -149,7 +149,7 @@ void main()
|
||||
//DrawTopPanelButton(BTN_ID_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active);
|
||||
|
||||
SelectList_Init(GAP, WIN_CONTENT_Y, PROCESS_LIST_W,
|
||||
Form.cheight-BOTPANEL_H-WIN_CONTENT_Y, false);
|
||||
Form.cheight-BOTPANEL_H-WIN_CONTENT_Y);
|
||||
SelectList_DrawBorder();
|
||||
|
||||
DrawBar(select_list.x-2, select_list.y+select_list.h+2,
|
||||
|
Loading…
Reference in New Issue
Block a user