From 9be11fb14a5f48d66e3a831016ae5065e4857fa9 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Wed, 4 Oct 2017 22:59:57 +0000 Subject: [PATCH] Fix OpenDialog filter (VERY big thanks to IgorA), rename libimg_lib.h to libimg.h and libio_lib.h to libio.h, Calypte uses string collection git-svn-id: svn://kolibrios.org@7049 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/Calypte/Calypte.c | 229 +++++++++--------- programs/cmm/browser/WebView.c | 4 +- programs/cmm/drvinst/drvinst.c | 2 +- programs/cmm/lib/collection.h | 19 +- .../cmm/lib/obj/{libimg_lib.h => libimg.h} | 2 +- programs/cmm/lib/obj/{libio_lib.h => libio.h} | 0 programs/cmm/lib/patterns/libimg_load_skin.h | 2 +- .../cmm/lib/patterns/simple_open_dialog.h | 14 +- programs/cmm/lib/strings.h | 21 ++ programs/cmm/liza/liza.c | 4 +- programs/cmm/mblocks/mblocks.c | 4 +- programs/cmm/mousecfg/mousecfg.c | 2 +- programs/cmm/panels_cfg/panels_cfg.c | 2 +- programs/cmm/pixie/pixie.c | 4 +- programs/cmm/pixie2/pixie.c | 4 +- .../cmm/software_widget/software_widget.c | 4 +- programs/cmm/the_bus/the_bus.c | 4 +- programs/cmm/tmpdisk/tmpdisk.c | 2 +- 18 files changed, 172 insertions(+), 151 deletions(-) rename programs/cmm/lib/obj/{libimg_lib.h => libimg.h} (94%) rename programs/cmm/lib/obj/{libio_lib.h => libio.h} (100%) diff --git a/programs/cmm/Calypte/Calypte.c b/programs/cmm/Calypte/Calypte.c index b7d758aa73..53af3a6955 100644 --- a/programs/cmm/Calypte/Calypte.c +++ b/programs/cmm/Calypte/Calypte.c @@ -1,13 +1,12 @@ //Calypte 0.35 - Leency //Calypte 0.15 - Punk Joker -#define MEMSIZE 1024*100 +#define MEMSIZE 1024*200 #ifndef AUTOBUILD #include "lang.h--" #endif - //===================================================// // // // LIB // @@ -19,26 +18,25 @@ #include "../lib/gui.h" #include "../lib/list_box.h" #include "../lib/menu.h" -//#include "../lib/collection.h" - +#include "../lib/collection.h" #include "../lib/obj/iconv.h" #include "../lib/obj/box_lib.h" -#include "../lib/obj/libio_lib.h" //TO CHECK: why opendial is a peace of shit! +#include "../lib/obj/libio.h" #include "../lib/obj/proc_lib.h" +//#include "../lib/obj/libini.h" #include "../lib/patterns/simple_open_dialog.h" - -char default_dir[] = "/rd/1"; -od_filter filter2 = { "TXT",0}; - //===================================================// // // // DATA // // // //===================================================// +char default_dir[] = "/rd/1"; +od_filter filter2 = { 8, "TXT\0\0" }; + /*========= MENU ==========*/ ?define MENU1 "File" ?define MENU2 "Encoding" @@ -89,7 +87,7 @@ int menu_encoding_x = NULL; int menu_reopen_x = NULL; /*======== MENU END ==========*/ -#define TITLE "Calypte v0.3" +#define TITLE "Calypte v0.37" char win_title[4096] = TITLE; #define TOPPANELH 23 @@ -107,12 +105,11 @@ dword old_width,old_height; dword bufpointer; dword bufsize; -dword draw_sruct; scroll_bar scroll_v = { SCROLL_SIZE,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}; scroll_bar scroll_h = { SCROLL_SIZE,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}; -//collection s; +collection s; //===================================================// // // @@ -120,22 +117,27 @@ scroll_bar scroll_h = { SCROLL_SIZE,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0x // // //===================================================// -void InitDlls() -{ - load_dll(boxlib, #box_lib_init, 0); - load_dll(libio, #libio_init, 1); - load_dll(iconv_lib, #iconv_open, 0); - load_dll(Proc_lib, #OpenDialog_init,0); - OpenDialog_init stdcall (#o_dialog); -} - void main() { int id; - InitDlls(); + load_dll(boxlib, #box_lib_init, 0); + load_dll(libio, #libio_init, 1); + //load_dll(libini, #lib_init, 1); + load_dll(iconv_lib, #iconv_open, 0); + load_dll(Proc_lib, #OpenDialog_init,0); + OpenDialog_init stdcall (#o_dialog); + + if (param) + { + draw_window(); + OpenFile(#param); + Prepare(); + DrawText(); + } - SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); + SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); + loop() { switch(WaitEvent()) @@ -171,80 +173,13 @@ void main() break; case evReDraw: - if (menu.list.cur_y) { - if (menu.list.cur_y == FILE_SUBMENU_ID_OPEN) EventOpenFile(); - if (menu.list.cur_y == FILE_SUBMENU_ID_CLOSE) EventCloseFile(); - if (menu.list.cur_y == FILE_SUBMENU_ID_PROPERTIES) EventShowFileProperties(); - if (menu.list.cur_y == FILE_SUBMENU_ID_EXIT) ExitProcess(); - - if (menu.list.cur_y > MENU_ID_ENCODING) && (menu.list.cur_y < MENU_ID_ENCODING + 10) - EventChangeEncoding(menu.list.cur_y - MENU_ID_ENCODING); - - if (menu.list.cur_y == FILE_SUBMENU_ID_TINYPAD) ReopenFileIn("/sys/tinypad"); - if (menu.list.cur_y == FILE_SUBMENU_ID_TEXTEDIT) ReopenFileIn("/sys/develop/t_edit"); - if (menu.list.cur_y == FILE_SUBMENU_ID_TEXTREAD) ReopenFileIn("/sys/txtread"); - if (menu.list.cur_y == FILE_SUBMENU_ID_WEBVIEW) ReopenFileIn("/sys/network/webview"); - if (menu.list.cur_y == FILE_SUBMENU_ID_FB2READ) ReopenFileIn("/sys/fb2read"); - if (menu.list.cur_y == FILE_SUBMENU_ID_HEXVIEW) ReopenFileIn("/sys/develop/heed"); - - - menu.list.cur_y = 0; - }; + if (menu.list.cur_y) EventMenuClick(); draw_window(); break; } } } -void ReopenFileIn(dword _app) -{ - RunProgram(_app, #param); -} - -void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected) -{ - menu.selected = _selected; - menu.show( - Form.left+5 + _menu_item_x, - Form.top+skin_height + TOPPANELH, - 140, - _menu_list, - _id); -} - -void EventOpenFile() -{ - OpenDialog_start stdcall (#o_dialog); - if (!o_dialog.status) return; - OpenFile(#openfile_path); - Prepare(); - draw_window(); -} - -void EventCloseFile() -{ - if (!bufpointer) return; - strcpy(#win_title, TITLE); - FreeBuf(); - draw_window(); -} - -void EventShowFileProperties() -{ -char ss_param[4096]; - if (!bufpointer) return; - sprintf(#ss_param, "-p %s", #param); - RunProgram("/sys/File managers/Eolite", #ss_param); -} - -void EventChangeEncoding(dword id) -{ - encoding = id; - OpenFile(#openfile_path); - Prepare(); - draw_window(); -} - int DrawMenuButton(dword x,y,id,text) { int textlen = strlen(text)*8; @@ -257,7 +192,7 @@ int DrawMenuButton(dword x,y,id,text) void draw_window() { system.color.get(); - DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title,0); + DefineAndDrawWindow(screen.width-WIN_W/2,screen.height-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title,0); GetProcessInfo(#Form, SelfInfo); DrawBar(0, 0, Form.cwidth, TOPPANELH-1, system.color.work); DrawBar(0, TOPPANELH-1, Form.cwidth, 1, system.color.work_dark); @@ -298,23 +233,12 @@ void OpenFile(dword _path) if (ReadFile(0, bufsize, bufpointer, #param) != 0) { bufpointer = 0; notify("'Error opening file'-E"); + return; } } if (encoding!=CH_CP866) ChangeCharset(charsets[encoding], "CP866", bufpointer); } -void FreeBuf() -{ - int i; - if (!bufpointer) return; - for (i=0; i= 4090) return 0; - if (element_offset[count]+strlen(in)+2 > data_size) { + return addn(in, strlen(in)); +} + +int collection::addn(dword in, len) { + if (count >= 4000) return 0; + if (element_offset[count]+len+2 > data_size) { increase_data_size(); - add(in); - return; + addn(in, len); + return 1; } - strcpy(data_start+element_offset[count], in); + strncpy(data_start+element_offset[count], in, len); count++; - element_offset[count] = element_offset[count-1] + strlen(in) + 1; + element_offset[count] = element_offset[count-1] + len + 1; return 1; } diff --git a/programs/cmm/lib/obj/libimg_lib.h b/programs/cmm/lib/obj/libimg.h similarity index 94% rename from programs/cmm/lib/obj/libimg_lib.h rename to programs/cmm/lib/obj/libimg.h index 3775e29fec..11343f4fd3 100644 --- a/programs/cmm/lib/obj/libimg_lib.h +++ b/programs/cmm/lib/obj/libimg.h @@ -15,7 +15,7 @@ #endif #ifndef INCLUDE_LIBIO_H -#include "../lib/obj/libio_lib.h" +#include "../lib/obj/libio.h" #endif :byte init_imglib_check; diff --git a/programs/cmm/lib/obj/libio_lib.h b/programs/cmm/lib/obj/libio.h similarity index 100% rename from programs/cmm/lib/obj/libio_lib.h rename to programs/cmm/lib/obj/libio.h diff --git a/programs/cmm/lib/patterns/libimg_load_skin.h b/programs/cmm/lib/patterns/libimg_load_skin.h index b9957309b7..4a2030d783 100644 --- a/programs/cmm/lib/patterns/libimg_load_skin.h +++ b/programs/cmm/lib/patterns/libimg_load_skin.h @@ -2,7 +2,7 @@ #define INCLUDE_LIBIMG_LOAD_SKIN_H #ifndef INCLUDE_LIBIMG_H -#include "../lib/obj/libimg_lib.h" +#include "../lib/obj/libimg.h" #endif :struct libimg_image { diff --git a/programs/cmm/lib/patterns/simple_open_dialog.h b/programs/cmm/lib/patterns/simple_open_dialog.h index 7fa5b37cf5..5ea08714e8 100644 --- a/programs/cmm/lib/patterns/simple_open_dialog.h +++ b/programs/cmm/lib/patterns/simple_open_dialog.h @@ -1,15 +1,17 @@ struct od_filter -{ - dword size; - byte end; -}; + { + dword size; //size = len(#ext) + sizeof(dword) + char ext[16]; + }; + proc_info pr_inf; char communication_area_name[] = "FFFFFFFF_open_dialog"; -char opendir_path[4096]; +char opendir_path[3072]; char open_dialog_path[] = "/rd/1/File managers/opendial"; char openfile_path[4096]; -char filename_area[256]; +char filename_area[1024]; + opendialog o_dialog = { 0, diff --git a/programs/cmm/lib/strings.h b/programs/cmm/lib/strings.h index 47d01d9fa2..0220addbf1 100644 --- a/programs/cmm/lib/strings.h +++ b/programs/cmm/lib/strings.h @@ -233,6 +233,18 @@ inline fastcall int strlcpy(dword ESI, EDI, EBX) return 0; } +:void strncpy(dword dst, src, len) +{ + while (len) + { + ESBYTE[dst] = ESBYTE[src]; + dst++; + src++; + len--; + } + ESBYTE[dst]=0; +} + /* inline fastcall void strtrim( ESI) { @@ -889,6 +901,15 @@ inline signed strcoll(dword text1,text2) return 0; } +replace_char(dword in_str, char from_char, to_char, int length) { + int i; + for (i=0; i