2017-10-03 16:55:12 +02:00
|
|
|
//Calypte 0.35 - Leency
|
2017-10-03 14:10:48 +02:00
|
|
|
//Calypte 0.15 - Punk Joker
|
|
|
|
|
2018-09-09 00:43:59 +02:00
|
|
|
/*
|
|
|
|
TODO
|
|
|
|
- word wrap
|
|
|
|
- draw by line
|
|
|
|
- text selection
|
|
|
|
*/
|
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
#define MEMSIZE 1024*200
|
2017-10-03 14:10:48 +02:00
|
|
|
|
2015-07-24 22:08:01 +02:00
|
|
|
#ifndef AUTOBUILD
|
|
|
|
#include "lang.h--"
|
|
|
|
#endif
|
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// LIB //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
#include "../lib/kolibri.h"
|
2018-04-03 15:57:56 +02:00
|
|
|
#include "../lib/fs.h"
|
2017-10-03 14:10:48 +02:00
|
|
|
#include "../lib/gui.h"
|
|
|
|
#include "../lib/list_box.h"
|
2017-10-05 00:59:57 +02:00
|
|
|
#include "../lib/collection.h"
|
2015-11-15 04:02:20 +01:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
#include "../lib/obj/iconv.h"
|
2017-10-03 16:55:12 +02:00
|
|
|
#include "../lib/obj/box_lib.h"
|
2017-10-05 00:59:57 +02:00
|
|
|
#include "../lib/obj/libio.h"
|
2017-10-03 14:10:48 +02:00
|
|
|
#include "../lib/obj/proc_lib.h"
|
2018-05-22 22:01:11 +02:00
|
|
|
#include "../lib/obj/librasterworks.h"
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
#include "../lib/patterns/simple_open_dialog.h"
|
2015-08-04 16:36:07 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// DATA //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
char default_dir[] = "/rd/1";
|
|
|
|
od_filter filter2 = { 8, "TXT\0\0" };
|
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
/*========= MENU ==========*/
|
|
|
|
?define MENU1 "File"
|
|
|
|
?define MENU2 "Encoding"
|
|
|
|
?define MENU3 "Reopen"
|
|
|
|
|
|
|
|
char menu_file_list[] =
|
|
|
|
"Open
|
|
|
|
Close
|
|
|
|
Properties
|
|
|
|
Exit";
|
|
|
|
|
|
|
|
char menu_encoding_list[] =
|
|
|
|
"UTF-8
|
|
|
|
KOI8-RU
|
|
|
|
CP1251
|
|
|
|
CP1252
|
|
|
|
ISO8859-5
|
|
|
|
CP866";
|
|
|
|
|
|
|
|
char menu_reopen_list[] =
|
|
|
|
"Tinypad
|
|
|
|
TextEdit
|
|
|
|
TextRead
|
|
|
|
WebView
|
|
|
|
FB2Read
|
|
|
|
HexView";
|
|
|
|
|
2018-05-22 22:01:11 +02:00
|
|
|
enum
|
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
MENU_ID_FILE=10,
|
|
|
|
FILE_SUBMENU_ID_OPEN=10,
|
|
|
|
FILE_SUBMENU_ID_CLOSE,
|
|
|
|
FILE_SUBMENU_ID_PROPERTIES,
|
|
|
|
FILE_SUBMENU_ID_EXIT,
|
|
|
|
|
|
|
|
MENU_ID_ENCODING=20,
|
|
|
|
|
|
|
|
MENU_ID_REOPEN=30,
|
|
|
|
FILE_SUBMENU_ID_TINYPAD=30,
|
|
|
|
FILE_SUBMENU_ID_TEXTEDIT,
|
|
|
|
FILE_SUBMENU_ID_TEXTREAD,
|
|
|
|
FILE_SUBMENU_ID_WEBVIEW,
|
|
|
|
FILE_SUBMENU_ID_FB2READ,
|
|
|
|
FILE_SUBMENU_ID_HEXVIEW
|
2015-07-24 20:15:43 +02:00
|
|
|
};
|
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
int menu_file_x = 6;
|
|
|
|
int menu_encoding_x = NULL;
|
|
|
|
int menu_reopen_x = NULL;
|
|
|
|
/*======== MENU END ==========*/
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2018-05-22 22:01:11 +02:00
|
|
|
#define TITLE "Calypte v0.38 dev"
|
2017-10-03 14:10:48 +02:00
|
|
|
char win_title[4096] = TITLE;
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
#define TOPPANELH 23
|
|
|
|
#define BOTPANELH 10
|
|
|
|
#define WIN_W 750
|
|
|
|
#define WIN_H 550
|
2017-10-03 16:55:12 +02:00
|
|
|
#define SCROLL_SIZE 15
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
proc_info Form;
|
|
|
|
llist rows;
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
int encoding;
|
|
|
|
|
|
|
|
dword old_width,old_height;
|
2015-07-24 20:15:43 +02:00
|
|
|
|
|
|
|
dword bufpointer;
|
|
|
|
dword bufsize;
|
|
|
|
|
2017-10-03 16:55:12 +02:00
|
|
|
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};
|
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
collection s;
|
2017-10-03 16:55:12 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// CODE //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
void main()
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
|
2017-10-03 16:55:12 +02:00
|
|
|
load_dll(boxlib, #box_lib_init, 0);
|
2017-10-03 14:10:48 +02:00
|
|
|
load_dll(libio, #libio_init, 1);
|
2017-10-05 00:59:57 +02:00
|
|
|
//load_dll(libini, #lib_init, 1);
|
2017-10-03 14:10:48 +02:00
|
|
|
load_dll(iconv_lib, #iconv_open, 0);
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
2018-05-22 22:01:11 +02:00
|
|
|
load_dll(librasterworks, #rasterworks_drawText,0);
|
2017-10-03 14:10:48 +02:00
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
if (param)
|
|
|
|
{
|
|
|
|
draw_window();
|
|
|
|
OpenFile(#param);
|
|
|
|
Prepare();
|
|
|
|
DrawText();
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
|
|
|
|
|
2015-07-24 20:15:43 +02:00
|
|
|
loop()
|
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
switch(WaitEvent())
|
|
|
|
{
|
2015-07-24 20:15:43 +02:00
|
|
|
case evMouse:
|
2017-10-03 14:10:48 +02:00
|
|
|
mouse.get();
|
|
|
|
rows.wheel_size = 3;
|
2018-05-22 22:01:11 +02:00
|
|
|
if (rows.MouseScroll(mouse.vert))
|
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
DrawText();
|
2015-11-15 04:02:20 +01:00
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
break;
|
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
case evButton:
|
2015-11-15 04:02:20 +01:00
|
|
|
id=GetButtonID();
|
2018-05-22 22:01:11 +02:00
|
|
|
if (id==1)
|
|
|
|
{
|
|
|
|
ExitProcess();
|
|
|
|
}
|
2017-10-03 16:55:12 +02:00
|
|
|
if (id==MENU_ID_FILE)
|
2018-05-22 22:01:11 +02:00
|
|
|
{
|
2017-10-03 16:55:12 +02:00
|
|
|
EventShowMenu(menu_file_x, #menu_file_list, MENU_ID_FILE, NULL);
|
2018-05-22 22:01:11 +02:00
|
|
|
}
|
2017-10-03 16:55:12 +02:00
|
|
|
if (id==MENU_ID_ENCODING)
|
2018-05-22 22:01:11 +02:00
|
|
|
{
|
2017-10-03 16:55:12 +02:00
|
|
|
EventShowMenu(menu_encoding_x, #menu_encoding_list, MENU_ID_ENCODING, encoding+1);
|
2018-05-22 22:01:11 +02:00
|
|
|
}
|
2017-10-03 16:55:12 +02:00
|
|
|
if (id==MENU_ID_REOPEN)
|
2018-05-22 22:01:11 +02:00
|
|
|
{
|
2017-10-03 16:55:12 +02:00
|
|
|
EventShowMenu(menu_reopen_x, #menu_reopen_list, MENU_ID_REOPEN, NULL);
|
2018-05-22 22:01:11 +02:00
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
break;
|
2015-11-15 04:02:20 +01:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
case evKey:
|
|
|
|
GetKeys();
|
|
|
|
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
|
2015-07-24 20:15:43 +02:00
|
|
|
{
|
2018-05-22 22:01:11 +02:00
|
|
|
if (key_scancode == SCAN_CODE_KEY_O)
|
|
|
|
{
|
|
|
|
EventOpenFile();
|
|
|
|
}
|
2015-08-10 09:55:50 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-05-22 22:01:11 +02:00
|
|
|
if (rows.ProcessKey(key_scancode))
|
|
|
|
{
|
|
|
|
DrawText();
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
break;
|
2017-10-03 14:10:48 +02:00
|
|
|
|
|
|
|
case evReDraw:
|
2018-05-22 22:01:11 +02:00
|
|
|
if (menu.list.cur_y)
|
|
|
|
{
|
|
|
|
EventMenuClick();
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
draw_window();
|
|
|
|
break;
|
2017-10-03 14:10:48 +02:00
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
int DrawMenuButton(dword x,y,id,text)
|
|
|
|
{
|
|
|
|
int textlen = strlen(text)*8;
|
|
|
|
int padding = 12;
|
|
|
|
DefineHiddenButton(x, y, textlen+padding+padding, TOPPANELH-2, id);
|
|
|
|
WriteText(x+padding,y+4, 0x90, MixColors(system.color.work, system.color.work_text, 70), text);
|
|
|
|
return textlen+padding+padding;
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
|
|
|
|
void draw_window()
|
|
|
|
{
|
2015-08-04 16:36:07 +02:00
|
|
|
system.color.get();
|
2017-10-05 00:59:57 +02:00
|
|
|
DefineAndDrawWindow(screen.width-WIN_W/2,screen.height-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title,0);
|
2015-07-24 20:15:43 +02:00
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2017-10-03 14:10:48 +02:00
|
|
|
DrawBar(0, 0, Form.cwidth, TOPPANELH-1, system.color.work);
|
|
|
|
DrawBar(0, TOPPANELH-1, Form.cwidth, 1, system.color.work_dark);
|
2015-08-04 16:36:07 +02:00
|
|
|
DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, system.color.work);
|
2015-07-24 20:15:43 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
menu_encoding_x = menu_file_x + DrawMenuButton(menu_file_x, 0, MENU_ID_FILE, MENU1);
|
|
|
|
menu_reopen_x = menu_encoding_x + DrawMenuButton(menu_encoding_x, 0, MENU_ID_ENCODING, MENU2);
|
|
|
|
DrawMenuButton(menu_reopen_x, 0, MENU_ID_REOPEN, MENU3);
|
|
|
|
|
2015-07-24 20:15:43 +02:00
|
|
|
if (old_width!=Form.width) || (old_height!=Form.height)
|
|
|
|
{
|
|
|
|
old_width = Form.width;
|
|
|
|
old_height = Form.height;
|
2015-11-15 04:02:20 +01:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
rows.no_selection = true;
|
|
|
|
rows.SetFont(8, 14, 0x90);
|
2017-10-03 16:55:12 +02:00
|
|
|
rows.SetSizes(0, TOPPANELH, Form.cwidth - SCROLL_SIZE, Form.cheight - TOPPANELH - BOTPANELH, 20);
|
2017-10-03 14:10:48 +02:00
|
|
|
rows.column_max = rows.w / rows.font_w;
|
|
|
|
|
2018-05-22 22:01:11 +02:00
|
|
|
if (bufpointer)
|
|
|
|
{
|
|
|
|
Prepare();
|
|
|
|
}
|
2017-10-03 14:10:48 +02:00
|
|
|
rows.CheckDoesValuesOkey();
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
2017-10-03 16:55:12 +02:00
|
|
|
DrawRectangle(rows.x+rows.w-1, rows.y, SCROLL_SIZE, rows.h-1, 0xEEEeee);
|
|
|
|
DrawText();
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
void OpenFile(dword _path)
|
2015-07-24 20:15:43 +02:00
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
strcpy(#param, _path);
|
|
|
|
sprintf(#win_title, "%s - %s", TITLE, #param);
|
|
|
|
rows.KeyHome();
|
|
|
|
file_size stdcall (#param);
|
2015-07-24 20:15:43 +02:00
|
|
|
bufsize = EBX;
|
|
|
|
if (bufsize)
|
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
bufpointer = mem_Free(bufpointer);
|
2015-07-24 20:15:43 +02:00
|
|
|
bufpointer = mem_Alloc(bufsize);
|
2018-05-22 22:01:11 +02:00
|
|
|
if (ReadFile(0, bufsize, bufpointer, #param) != 0)
|
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
bufpointer = 0;
|
|
|
|
notify("'Error opening file'-E");
|
2017-10-05 00:59:57 +02:00
|
|
|
return;
|
2017-10-03 14:10:48 +02:00
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
2018-05-22 22:01:11 +02:00
|
|
|
if (encoding!=CH_CP866)
|
|
|
|
{
|
|
|
|
ChangeCharset(charsets[encoding], "CP866", bufpointer);
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
|
|
|
|
2018-05-22 22:01:11 +02:00
|
|
|
enum
|
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
PARSE_CALCULATE_ROWS_COUNT,
|
|
|
|
PARSE_DRAW_PREPARE,
|
|
|
|
};
|
2018-05-22 22:01:11 +02:00
|
|
|
|
2017-10-03 14:10:48 +02:00
|
|
|
void Parse(int mode)
|
2015-07-24 20:15:43 +02:00
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
int pos=0;
|
|
|
|
int sub_pos=0;
|
2015-07-24 20:15:43 +02:00
|
|
|
int len_str = 0;
|
2017-10-03 14:10:48 +02:00
|
|
|
bool do_eof = false;
|
2015-07-24 20:15:43 +02:00
|
|
|
word bukva[2];
|
2017-10-03 14:10:48 +02:00
|
|
|
|
2015-07-24 20:15:43 +02:00
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
while(1)
|
|
|
|
{
|
2015-11-15 04:02:20 +01:00
|
|
|
bukva = DSBYTE[bufpointer+pos+len_str];
|
2015-07-24 20:15:43 +02:00
|
|
|
if (bukva=='\0')
|
|
|
|
{
|
2017-10-03 14:10:48 +02:00
|
|
|
do_eof = true;
|
2015-07-24 20:15:43 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-05-22 22:01:11 +02:00
|
|
|
if (bukva==0x0a)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len_str++;
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
2017-10-03 14:10:48 +02:00
|
|
|
if (len_str<=rows.column_max)
|
2015-07-24 20:15:43 +02:00
|
|
|
{
|
2018-05-22 22:01:11 +02:00
|
|
|
if (mode==PARSE_DRAW_PREPARE)
|
|
|
|
{
|
|
|
|
s.addn(bufpointer+pos, len_str);
|
|
|
|
}
|
2017-10-03 14:10:48 +02:00
|
|
|
pos += len_str+1;
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-22 22:01:11 +02:00
|
|
|
if (mode==PARSE_DRAW_PREPARE)
|
|
|
|
{
|
|
|
|
s.addn(bufpointer+pos, rows.column_max);
|
|
|
|
}
|
2017-10-03 14:10:48 +02:00
|
|
|
pos += rows.column_max;
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
2017-10-03 14:10:48 +02:00
|
|
|
sub_pos++;
|
2018-05-22 22:01:11 +02:00
|
|
|
if (mode==PARSE_CALCULATE_ROWS_COUNT) && (do_eof)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (mode==PARSE_DRAW_PREPARE) && (pos>=bufsize-1)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
len_str = 0;
|
|
|
|
}
|
2017-10-03 14:10:48 +02:00
|
|
|
if (mode == PARSE_CALCULATE_ROWS_COUNT)
|
|
|
|
{
|
|
|
|
rows.count = sub_pos;
|
|
|
|
Parse(PARSE_DRAW_PREPARE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Prepare()
|
|
|
|
{
|
|
|
|
Parse(PARSE_CALCULATE_ROWS_COUNT);
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawText()
|
|
|
|
{
|
2017-10-03 16:55:12 +02:00
|
|
|
int i=0, top;
|
2017-10-03 14:10:48 +02:00
|
|
|
|
2018-05-22 22:01:11 +02:00
|
|
|
if (rows.count<rows.visible)
|
|
|
|
{
|
|
|
|
top = rows.count;
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
else
|
|
|
|
{
|
2018-05-22 22:01:11 +02:00
|
|
|
if (rows.count-rows.first<=rows.visible)
|
|
|
|
{
|
|
|
|
top = rows.count-rows.first-1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
top = rows.visible;
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
2017-10-03 14:10:48 +02:00
|
|
|
|
2018-05-22 22:01:11 +02:00
|
|
|
if (bufpointer)
|
2015-07-24 20:15:43 +02:00
|
|
|
{
|
2018-05-22 22:01:11 +02:00
|
|
|
for (i=0; i<top; i++)
|
|
|
|
{
|
|
|
|
DrawBar(0, i*rows.item_h+TOPPANELH, rows.w, rows.item_h, 0xFFFFFF);
|
|
|
|
WriteText(2, i*rows.item_h+TOPPANELH, 0x90, 0x000000, s.get(i+rows.first));
|
|
|
|
}
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
2017-10-03 14:10:48 +02:00
|
|
|
DrawBar(0, i*rows.item_h+rows.y, rows.w, -i*rows.item_h + rows.h, 0xFFFfff);
|
2017-10-03 16:55:12 +02:00
|
|
|
DrawVerticalScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawVerticalScroll()
|
|
|
|
{
|
|
|
|
scroll_v.max_area = rows.count;
|
|
|
|
scroll_v.cur_area = rows.visible;
|
|
|
|
scroll_v.position = rows.first;
|
|
|
|
scroll_v.start_y = rows.y;
|
|
|
|
scroll_v.size_y = rows.h;
|
|
|
|
scroll_v.start_x = rows.w + rows.x -1;
|
|
|
|
scroll_v.all_redraw = 0;
|
|
|
|
scrollbar_v_draw(#scroll_v);
|
2015-07-24 20:15:43 +02:00
|
|
|
}
|
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// EVENTS //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
void EventMenuClick()
|
|
|
|
{
|
|
|
|
switch(menu.list.cur_y)
|
|
|
|
{
|
|
|
|
//File
|
2018-05-22 22:01:11 +02:00
|
|
|
case FILE_SUBMENU_ID_OPEN:
|
|
|
|
EventOpenFile();
|
|
|
|
break;
|
|
|
|
case FILE_SUBMENU_ID_CLOSE:
|
|
|
|
EventCloseFile();
|
|
|
|
break;
|
|
|
|
case FILE_SUBMENU_ID_PROPERTIES:
|
|
|
|
EventShowFileProperties();
|
|
|
|
break;
|
|
|
|
case FILE_SUBMENU_ID_EXIT:
|
|
|
|
ExitProcess();
|
|
|
|
break;
|
2017-10-05 00:59:57 +02:00
|
|
|
//Encoding
|
2018-05-22 22:01:11 +02:00
|
|
|
case MENU_ID_ENCODING...MENU_ID_ENCODING+9:
|
|
|
|
EventChangeEncoding(menu.list.cur_y-MENU_ID_ENCODING);
|
|
|
|
break;
|
2017-10-05 00:59:57 +02:00
|
|
|
//Reopen
|
2018-05-22 22:01:11 +02:00
|
|
|
case FILE_SUBMENU_ID_TINYPAD:
|
|
|
|
EventOpenFileInAnotherProgram("/sys/tinypad");
|
|
|
|
break;
|
|
|
|
case FILE_SUBMENU_ID_TEXTEDIT:
|
|
|
|
EventOpenFileInAnotherProgram("/sys/develop/t_edit");
|
|
|
|
break;
|
|
|
|
case FILE_SUBMENU_ID_TEXTREAD:
|
|
|
|
EventOpenFileInAnotherProgram("/sys/txtread");
|
|
|
|
break;
|
|
|
|
case FILE_SUBMENU_ID_WEBVIEW:
|
|
|
|
EventOpenFileInAnotherProgram("/sys/network/webview");
|
|
|
|
break;
|
|
|
|
case FILE_SUBMENU_ID_FB2READ:
|
|
|
|
EventOpenFileInAnotherProgram("/sys/fb2read");
|
|
|
|
break;
|
|
|
|
case FILE_SUBMENU_ID_HEXVIEW:
|
|
|
|
EventOpenFileInAnotherProgram("/sys/develop/heed");
|
|
|
|
break;
|
2017-10-05 00:59:57 +02:00
|
|
|
}
|
|
|
|
menu.list.cur_y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected)
|
|
|
|
{
|
|
|
|
menu.selected = _selected;
|
2018-05-22 22:01:11 +02:00
|
|
|
menu.show(Form.left+5 + _menu_item_x, Form.top+skin_height + TOPPANELH, 140, _menu_list, _id);
|
2017-10-05 00:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventOpenFile()
|
|
|
|
{
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
2018-05-22 22:01:11 +02:00
|
|
|
if (o_dialog.status)
|
|
|
|
{
|
|
|
|
OpenFile(#openfile_path);
|
|
|
|
Prepare();
|
|
|
|
draw_window();
|
|
|
|
}
|
2017-10-05 00:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventCloseFile()
|
|
|
|
{
|
2018-05-22 22:01:11 +02:00
|
|
|
if (bufpointer)
|
|
|
|
{
|
|
|
|
s.drop();
|
|
|
|
bufpointer = mem_Free(bufpointer);
|
|
|
|
strcpy(#win_title, TITLE);
|
|
|
|
draw_window();
|
|
|
|
}
|
2017-10-05 00:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventShowFileProperties()
|
|
|
|
{
|
2018-05-22 22:01:11 +02:00
|
|
|
char ss_param[4096];
|
|
|
|
if (bufpointer)
|
|
|
|
{
|
|
|
|
sprintf(#ss_param, "-p %s", #param);
|
|
|
|
RunProgram("/sys/File managers/Eolite", #ss_param);
|
|
|
|
}
|
2017-10-05 00:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventChangeEncoding(dword id)
|
|
|
|
{
|
|
|
|
encoding = id;
|
|
|
|
OpenFile(#openfile_path);
|
|
|
|
Prepare();
|
|
|
|
draw_window();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventOpenFileInAnotherProgram(dword _app)
|
|
|
|
{
|
|
|
|
RunProgram(_app, #param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-05-22 22:01:11 +02:00
|
|
|
stop:
|