diff --git a/programs/cmm/Calypte/Calypte.c b/programs/cmm/Calypte/Calypte.c index b7d758aa7..53af3a695 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 3775e29fe..11343f4fd 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 b9957309b..4a2030d78 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 7fa5b37cf..5ea08714e 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 47d01d9fa..0220addbf 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