2020-04-21 22:49:38 +02:00
|
|
|
|
#define MEMSIZE 1024*80
|
2015-09-07 17:07:51 +02:00
|
|
|
|
|
2018-10-15 00:02:13 +02:00
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
|
|
|
|
// LIB //
|
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
|
|
|
|
|
2015-11-06 15:55:25 +01:00
|
|
|
|
#include "../lib/io.h"
|
2018-05-22 14:08:24 +02:00
|
|
|
|
#include "../lib/gui.h"
|
2015-09-07 17:07:51 +02:00
|
|
|
|
#include "../lib/list_box.h"
|
2018-05-22 14:04:44 +02:00
|
|
|
|
#include "../lib/kfont.h"
|
2018-04-16 11:33:37 +02:00
|
|
|
|
|
2015-09-07 17:07:51 +02:00
|
|
|
|
#include "../lib/obj/box_lib.h"
|
|
|
|
|
#include "../lib/obj/libini.h"
|
2018-04-16 11:33:37 +02:00
|
|
|
|
#include "../lib/obj/libimg.h"
|
2015-09-07 17:07:51 +02:00
|
|
|
|
#include "../lib/obj/iconv.h"
|
|
|
|
|
#include "../lib/obj/proc_lib.h"
|
2018-04-16 11:33:37 +02:00
|
|
|
|
|
2015-09-07 17:07:51 +02:00
|
|
|
|
#include "../lib/patterns/simple_open_dialog.h"
|
|
|
|
|
|
2018-10-15 00:02:13 +02:00
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
2020-04-21 22:49:38 +02:00
|
|
|
|
// INTERNAL INCLUDES //
|
2018-10-15 00:02:13 +02:00
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
proc_info Form;
|
|
|
|
|
llist list;
|
|
|
|
|
|
2015-09-07 17:07:51 +02:00
|
|
|
|
#define TOOLBAR_H 34
|
2020-04-14 01:11:07 +02:00
|
|
|
|
#define TOOLBAR_ICON_WIDTH 24
|
|
|
|
|
#define TOOLBAR_ICON_HEIGHT 22
|
2015-11-21 22:12:38 +01:00
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
dword bg_color;
|
|
|
|
|
dword text_color;
|
|
|
|
|
|
|
|
|
|
#include "search.h"
|
|
|
|
|
#include "prepare_page.h"
|
|
|
|
|
#include "data.h"
|
|
|
|
|
|
|
|
|
|
int encoding;
|
|
|
|
|
int curcol_scheme;
|
2018-10-15 00:02:13 +02:00
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
#include "ini.h"
|
2018-10-15 00:02:13 +02:00
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
|
|
|
|
// DATA //
|
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
2015-09-07 17:07:51 +02:00
|
|
|
|
|
|
|
|
|
scroll_bar scroll = { 15,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};
|
|
|
|
|
|
|
|
|
|
char title[4196];
|
|
|
|
|
|
2018-04-03 14:45:08 +02:00
|
|
|
|
bool help_opened = false;
|
2018-10-15 00:02:13 +02:00
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
int charsets_mx,
|
|
|
|
|
reopenin_mx,
|
|
|
|
|
colscheme_mx,
|
|
|
|
|
search_mx;
|
2015-09-07 17:07:51 +02:00
|
|
|
|
|
|
|
|
|
enum {
|
2015-12-14 15:50:28 +01:00
|
|
|
|
OPEN_FILE,
|
2015-09-07 17:07:51 +02:00
|
|
|
|
MAGNIFY_MINUS,
|
|
|
|
|
MAGNIFY_PLUS,
|
2020-04-21 22:49:38 +02:00
|
|
|
|
CHANGE_CHARSET,
|
|
|
|
|
REOPEN_IN_APP,
|
2015-09-07 17:07:51 +02:00
|
|
|
|
SHOW_INFO,
|
2018-10-15 00:02:13 +02:00
|
|
|
|
SHOW_FILE_PROPERTIES,
|
2020-04-21 22:49:38 +02:00
|
|
|
|
COLOR_SCHEME,
|
|
|
|
|
SEARCH_BTN,
|
|
|
|
|
BTN_FIND_NEXT,
|
|
|
|
|
BTN_FIND_CLOSE
|
2015-09-07 17:07:51 +02:00
|
|
|
|
};
|
|
|
|
|
|
2020-04-13 15:16:55 +02:00
|
|
|
|
dword menu_id;
|
|
|
|
|
|
2018-10-15 00:02:13 +02:00
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
|
|
|
|
// CODE //
|
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
|
|
|
|
|
2015-11-21 22:12:38 +01:00
|
|
|
|
void InitDlls()
|
|
|
|
|
{
|
|
|
|
|
load_dll(boxlib, #box_lib_init, 0);
|
|
|
|
|
load_dll(libio, #libio_init, 1);
|
|
|
|
|
load_dll(libimg, #libimg_init, 1);
|
|
|
|
|
load_dll(libini, #lib_init, 1);
|
|
|
|
|
load_dll(iconv_lib, #iconv_open, 0);
|
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 17:07:51 +02:00
|
|
|
|
void main()
|
2015-11-21 22:12:38 +01:00
|
|
|
|
{
|
2015-12-18 22:10:45 +01:00
|
|
|
|
InitDlls();
|
2015-09-07 17:07:51 +02:00
|
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
2018-10-31 22:22:48 +01:00
|
|
|
|
if (param) strcpy(#openfile_path, #param);
|
2018-05-22 14:04:44 +02:00
|
|
|
|
LoadIniSettings();
|
2018-10-15 00:02:13 +02:00
|
|
|
|
EventSetColorScheme(curcol_scheme);
|
2016-12-21 20:50:13 +01:00
|
|
|
|
kfont.init(DEFAULT_FONT);
|
2015-09-07 17:07:51 +02:00
|
|
|
|
Libimg_LoadImage(#skin, abspath("toolbar.png"));
|
2020-04-21 22:49:38 +02:00
|
|
|
|
LoadFile(#param);
|
2015-09-07 17:07:51 +02:00
|
|
|
|
list.no_selection = true;
|
2018-04-16 00:44:36 +02:00
|
|
|
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
2015-09-07 17:07:51 +02:00
|
|
|
|
loop()
|
|
|
|
|
{
|
2015-11-21 22:12:38 +01:00
|
|
|
|
switch(WaitEvent())
|
|
|
|
|
{
|
|
|
|
|
case evMouse:
|
|
|
|
|
HandleMouseEvent();
|
2015-09-07 17:07:51 +02:00
|
|
|
|
break;
|
2015-11-21 22:12:38 +01:00
|
|
|
|
case evKey:
|
|
|
|
|
HandleKeyEvent();
|
|
|
|
|
break;
|
|
|
|
|
case evButton:
|
|
|
|
|
HandleButtonEvent();
|
|
|
|
|
break;
|
|
|
|
|
case evReDraw:
|
2020-04-13 15:16:55 +02:00
|
|
|
|
if (CheckActiveProcess(Form.ID)) EventMenuClick();
|
2015-11-21 22:12:38 +01:00
|
|
|
|
draw_window();
|
|
|
|
|
}
|
2015-09-07 17:07:51 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 00:02:13 +02:00
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
2020-04-21 22:49:38 +02:00
|
|
|
|
// EVENT HANDLERS //
|
2018-10-15 00:02:13 +02:00
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
2015-11-21 22:12:38 +01:00
|
|
|
|
|
2015-12-17 16:48:28 +01:00
|
|
|
|
void HandleButtonEvent()
|
|
|
|
|
{
|
2020-04-21 22:49:38 +02:00
|
|
|
|
int btn = GetButtonID();
|
2015-12-17 16:48:28 +01:00
|
|
|
|
if (btn==1) {
|
|
|
|
|
SaveIniSettings();
|
|
|
|
|
ExitProcess();
|
|
|
|
|
}
|
2020-04-21 22:49:38 +02:00
|
|
|
|
switch(btn-10)
|
2015-11-21 22:12:38 +01:00
|
|
|
|
{
|
2015-12-17 16:48:28 +01:00
|
|
|
|
case OPEN_FILE:
|
2020-04-21 22:49:38 +02:00
|
|
|
|
EventOpenDialog();
|
2015-12-17 16:48:28 +01:00
|
|
|
|
break;
|
2018-04-03 14:45:08 +02:00
|
|
|
|
case SHOW_FILE_PROPERTIES:
|
|
|
|
|
EventShowFileProperties();
|
|
|
|
|
break;
|
2015-12-17 16:48:28 +01:00
|
|
|
|
case MAGNIFY_PLUS:
|
|
|
|
|
EventMagnifyPlus();
|
|
|
|
|
break;
|
|
|
|
|
case MAGNIFY_MINUS:
|
|
|
|
|
EventMagnifyMinus();
|
|
|
|
|
break;
|
2020-04-21 22:49:38 +02:00
|
|
|
|
case CHANGE_CHARSET:
|
|
|
|
|
EventShowCharsetsList();
|
2015-12-17 16:48:28 +01:00
|
|
|
|
break;
|
2020-04-21 22:49:38 +02:00
|
|
|
|
case REOPEN_IN_APP:
|
2018-10-15 00:02:13 +02:00
|
|
|
|
EventShowReopenMenu();
|
|
|
|
|
break;
|
|
|
|
|
case COLOR_SCHEME:
|
|
|
|
|
EventShowColorSchemesList();
|
2015-12-17 16:48:28 +01:00
|
|
|
|
break;
|
|
|
|
|
case SHOW_INFO:
|
|
|
|
|
EventShowInfo();
|
|
|
|
|
break;
|
2020-04-21 22:49:38 +02:00
|
|
|
|
case SEARCH_BTN:
|
|
|
|
|
if (search.visible) {
|
|
|
|
|
search.hide();
|
|
|
|
|
} else {
|
|
|
|
|
search.show();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case BTN_FIND_NEXT:
|
|
|
|
|
EventSearchNext();
|
|
|
|
|
break;
|
|
|
|
|
case BTN_FIND_CLOSE:
|
|
|
|
|
search.hide();
|
|
|
|
|
break;
|
2015-11-21 22:12:38 +01:00
|
|
|
|
}
|
2015-09-07 17:07:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-17 16:48:28 +01:00
|
|
|
|
void HandleKeyEvent()
|
2015-09-07 17:07:51 +02:00
|
|
|
|
{
|
2020-04-21 22:49:38 +02:00
|
|
|
|
int new_y;
|
2015-12-17 16:48:28 +01:00
|
|
|
|
if (help_opened) {
|
|
|
|
|
help_opened = false;
|
|
|
|
|
DrawPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GetKeys();
|
|
|
|
|
if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
|
|
|
|
|
switch (key_scancode)
|
|
|
|
|
{
|
2018-04-03 14:45:08 +02:00
|
|
|
|
case SCAN_CODE_KEY_O:
|
2020-04-21 22:49:38 +02:00
|
|
|
|
EventOpenDialog();
|
|
|
|
|
return;
|
2018-04-03 14:45:08 +02:00
|
|
|
|
case SCAN_CODE_KEY_I:
|
|
|
|
|
EventShowFileProperties();
|
2020-04-21 22:49:38 +02:00
|
|
|
|
return;
|
2020-04-15 22:55:42 +02:00
|
|
|
|
case SCAN_CODE_PLUS:
|
2015-12-17 16:48:28 +01:00
|
|
|
|
case SCAN_CODE_UP:
|
|
|
|
|
EventMagnifyPlus();
|
2020-04-21 22:49:38 +02:00
|
|
|
|
return;
|
2015-12-17 16:48:28 +01:00
|
|
|
|
case SCAN_CODE_DOWN:
|
2020-04-15 22:55:42 +02:00
|
|
|
|
case SCAN_CODE_MINUS:
|
2015-12-17 16:48:28 +01:00
|
|
|
|
EventMagnifyMinus();
|
2020-04-21 22:49:38 +02:00
|
|
|
|
return;
|
2018-04-03 14:45:08 +02:00
|
|
|
|
case SCAN_CODE_KEY_E:
|
2018-10-15 00:02:13 +02:00
|
|
|
|
EventShowReopenMenu();
|
2020-04-21 22:49:38 +02:00
|
|
|
|
return;
|
2015-12-17 16:48:28 +01:00
|
|
|
|
case SCAN_CODE_TAB:
|
2020-04-21 22:49:38 +02:00
|
|
|
|
EventShowCharsetsList();
|
|
|
|
|
return;
|
|
|
|
|
case SCAN_CODE_KEY_F:
|
|
|
|
|
search.show();
|
|
|
|
|
return;
|
|
|
|
|
case SCAN_CODE_HOME:
|
|
|
|
|
list.KeyHome();
|
|
|
|
|
DrawPage();
|
2015-09-07 17:07:51 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-21 22:49:38 +02:00
|
|
|
|
switch (key_scancode)
|
|
|
|
|
{
|
|
|
|
|
case SCAN_CODE_F1:
|
|
|
|
|
EventShowInfo();
|
|
|
|
|
return;
|
|
|
|
|
case SCAN_CODE_ESC:
|
|
|
|
|
search.hide();
|
|
|
|
|
return;
|
|
|
|
|
case SCAN_CODE_ENTER:
|
|
|
|
|
if (! search_box.flags & ed_focus) return;
|
|
|
|
|
case SCAN_CODE_F3:
|
|
|
|
|
EventSearchNext();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!search.edit_key()) {
|
|
|
|
|
if (list.ProcessKey(key_scancode)) DrawPage();
|
|
|
|
|
}
|
2015-12-17 16:48:28 +01:00
|
|
|
|
}
|
2015-09-07 17:07:51 +02:00
|
|
|
|
|
2015-12-17 16:48:28 +01:00
|
|
|
|
void HandleMouseEvent()
|
|
|
|
|
{
|
|
|
|
|
mouse.get();
|
|
|
|
|
list.wheel_size = 7;
|
|
|
|
|
if (list.MouseScroll(mouse.vert)) {
|
|
|
|
|
DrawPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
scrollbar_v_mouse (#scroll);
|
|
|
|
|
if (list.first != scroll.position) {
|
|
|
|
|
list.first = scroll.position;
|
|
|
|
|
DrawPage();
|
2015-09-07 17:07:51 +02:00
|
|
|
|
}
|
2020-04-21 22:49:38 +02:00
|
|
|
|
search.edit_mouse();
|
2015-09-07 17:07:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
|
|
|
|
// EVENTS //
|
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
|
|
bool EventSearchNext()
|
|
|
|
|
{
|
|
|
|
|
int new_y = search.find_next(list.first, bg_color);
|
|
|
|
|
if (new_y) {
|
|
|
|
|
list.first = new_y / list.item_h;
|
|
|
|
|
list.CheckDoesValuesOkey();
|
|
|
|
|
DrawPage();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-17 16:48:28 +01:00
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
void EventOpenDialog()
|
2015-09-07 17:07:51 +02:00
|
|
|
|
{
|
2015-12-17 16:48:28 +01:00
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
2018-05-22 14:04:44 +02:00
|
|
|
|
if (o_dialog.status) {
|
2020-04-21 22:49:38 +02:00
|
|
|
|
LoadFile(#openfile_path);
|
|
|
|
|
search.clear();
|
|
|
|
|
ParseAndPaint();
|
2018-05-22 14:04:44 +02:00
|
|
|
|
}
|
2015-09-07 17:07:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-03 14:45:08 +02:00
|
|
|
|
void EventShowFileProperties()
|
|
|
|
|
{
|
|
|
|
|
char ss_param[4096];
|
|
|
|
|
if (!param) return;
|
2020-04-05 21:29:24 +02:00
|
|
|
|
strcpy(#ss_param, "-p ");
|
|
|
|
|
strcpy(#ss_param+3, #param);
|
2018-10-14 12:47:23 +02:00
|
|
|
|
RunProgram("/sys/File managers/Eolite", #ss_param);
|
2018-04-03 14:45:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-17 16:48:28 +01:00
|
|
|
|
void EventMagnifyPlus()
|
2015-09-07 17:07:51 +02:00
|
|
|
|
{
|
2016-12-21 20:50:13 +01:00
|
|
|
|
kfont.size.pt++;
|
|
|
|
|
if(!kfont.changeSIZE())
|
|
|
|
|
kfont.size.pt--;
|
2015-12-17 16:48:28 +01:00
|
|
|
|
else
|
2020-04-21 22:49:38 +02:00
|
|
|
|
ParseAndPaint();
|
2015-12-17 16:48:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventMagnifyMinus()
|
|
|
|
|
{
|
2016-12-21 20:50:13 +01:00
|
|
|
|
kfont.size.pt--;
|
|
|
|
|
if(!kfont.changeSIZE())
|
|
|
|
|
kfont.size.pt++;
|
2015-12-17 16:48:28 +01:00
|
|
|
|
else
|
2020-04-21 22:49:38 +02:00
|
|
|
|
ParseAndPaint();
|
2015-12-17 16:48:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
void EventShowCharsetsList()
|
2018-10-15 00:02:13 +02:00
|
|
|
|
{
|
2020-04-21 22:49:38 +02:00
|
|
|
|
menu_id = CHANGE_CHARSET;
|
2020-04-13 16:47:37 +02:00
|
|
|
|
open_lmenu(Form.left+5 + charsets_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT,
|
2020-05-06 00:38:26 +02:00
|
|
|
|
encoding+1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866\nAUTO");
|
2018-10-15 00:02:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventShowReopenMenu()
|
2015-12-17 16:48:28 +01:00
|
|
|
|
{
|
2020-04-21 22:49:38 +02:00
|
|
|
|
menu_id = REOPEN_IN_APP;
|
2020-04-13 15:16:55 +02:00
|
|
|
|
open_lmenu(Form.left+5 + reopenin_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, 0,
|
|
|
|
|
"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther");
|
2015-12-17 16:48:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 00:02:13 +02:00
|
|
|
|
void EventShowColorSchemesList()
|
2015-12-17 16:48:28 +01:00
|
|
|
|
{
|
2020-04-21 22:49:38 +02:00
|
|
|
|
menu_id = COLOR_SCHEME;
|
|
|
|
|
open_lmenu(Form.left+2 + colscheme_mx + 26,
|
|
|
|
|
Form.top+29+skin_height, MENU_ALIGN_TOP_RIGHT,
|
2020-04-13 15:16:55 +02:00
|
|
|
|
curcol_scheme+1, #color_scheme_names);
|
2018-10-15 00:02:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventSetColorScheme(dword _setn)
|
|
|
|
|
{
|
|
|
|
|
curcol_scheme = _setn;
|
|
|
|
|
bg_color = color_schemes[curcol_scheme*2];
|
|
|
|
|
text_color = color_schemes[curcol_scheme*2+1];
|
2020-04-21 22:49:38 +02:00
|
|
|
|
if (list.count) ParseAndPaint();
|
2015-12-17 16:48:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventShowInfo() {
|
|
|
|
|
help_opened = true;
|
2020-04-21 22:49:38 +02:00
|
|
|
|
DrawBar(list.x, list.y, list.w, list.h, bg_color);
|
|
|
|
|
WriteText(list.x + 10, list.y + 10, 10000001b, text_color, VERSION);
|
2020-05-06 00:38:26 +02:00
|
|
|
|
WriteTextLines(list.x + 10, list.y+40, 10010000b, text_color, ABOUT, 20);
|
2015-09-07 17:07:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
void EventChangeCharset(dword id)
|
2018-10-14 12:47:23 +02:00
|
|
|
|
{
|
|
|
|
|
encoding = id;
|
2020-04-21 22:49:38 +02:00
|
|
|
|
LoadFile(#openfile_path);
|
|
|
|
|
ParseAndPaint();
|
2018-10-14 12:47:23 +02:00
|
|
|
|
draw_window();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
void EventOpenFileInAnotherProgram(dword _id)
|
2018-10-14 12:47:23 +02:00
|
|
|
|
{
|
2020-04-21 22:49:38 +02:00
|
|
|
|
dword app;
|
2018-10-15 00:02:13 +02:00
|
|
|
|
byte open_param[4096];
|
2020-04-21 22:49:38 +02:00
|
|
|
|
switch(_id) {
|
2020-05-15 10:09:03 +02:00
|
|
|
|
case 0: app = "/sys/tinypad"; break;
|
|
|
|
|
case 1: app = "/sys/develop/t_edit"; break;
|
|
|
|
|
case 2: app = "/sys/network/webview"; break;
|
|
|
|
|
case 3: app = "/sys/fb2read"; break;
|
|
|
|
|
case 4: app = "/sys/develop/heed"; break;
|
|
|
|
|
case 5: open_param[0]='~';
|
2020-04-05 21:29:24 +02:00
|
|
|
|
strcpy(#open_param+1,#param);
|
2018-10-15 00:02:13 +02:00
|
|
|
|
RunProgram("/sys/@open", #open_param);
|
2020-05-15 10:09:03 +02:00
|
|
|
|
return;
|
2018-10-14 12:47:23 +02:00
|
|
|
|
}
|
2020-04-21 22:49:38 +02:00
|
|
|
|
RunProgram(app, #param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventMenuClick()
|
|
|
|
|
{
|
|
|
|
|
dword click_id = get_menu_click();
|
|
|
|
|
|
|
|
|
|
if (click_id) && (menu_id)
|
|
|
|
|
{
|
|
|
|
|
if (menu_id == CHANGE_CHARSET) EventChangeCharset(click_id-1);
|
|
|
|
|
else if (menu_id == REOPEN_IN_APP) EventOpenFileInAnotherProgram(click_id-1);
|
|
|
|
|
else if (menu_id == COLOR_SCHEME) EventSetColorScheme(click_id-1);
|
|
|
|
|
else notify("'Error: wrong menu number'E");
|
|
|
|
|
}
|
|
|
|
|
menu_id = NULL;
|
2018-10-14 12:47:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 00:02:13 +02:00
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
|
|
|
|
// DRAWS AND OTHER FUNCS //
|
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
2015-12-17 16:48:28 +01:00
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
void LoadFile(dword f_path)
|
2015-09-07 17:07:51 +02:00
|
|
|
|
{
|
|
|
|
|
int tmp;
|
|
|
|
|
if (ESBYTE[f_path]) {
|
|
|
|
|
strcpy(#param, f_path);
|
2020-04-21 22:49:38 +02:00
|
|
|
|
if (!io.read(#param)) goto NO_DATA;
|
2015-09-07 17:07:51 +02:00
|
|
|
|
strcpy(#title, #param);
|
|
|
|
|
strcat(#title, " - Text Reader");
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-04-21 22:49:38 +02:00
|
|
|
|
NO_DATA:
|
2015-09-07 17:07:51 +02:00
|
|
|
|
if (list.count) return;
|
2015-11-21 22:12:38 +01:00
|
|
|
|
io.buffer_data = INTRO_TEXT;
|
2015-09-07 17:07:51 +02:00
|
|
|
|
strcpy(#title, "Text Reader");
|
|
|
|
|
}
|
2020-05-06 00:38:26 +02:00
|
|
|
|
|
|
|
|
|
// Autodetecting encoding
|
|
|
|
|
if (encoding==CH_AUTO) {
|
|
|
|
|
if (strstr(io.buffer_data, "\208\190")) ChangeCharset(CH_UTF8, "CP866", io.buffer_data);
|
|
|
|
|
else if (chrnum(io.buffer_data, '\246')>5) || (strstr(io.buffer_data, "<EFBFBD><EFBFBD>")) ChangeCharset(CH_CP1251, "CP866", io.buffer_data);
|
|
|
|
|
} else {
|
|
|
|
|
if (encoding!=CH_CP866) ChangeCharset(encoding, "CP866", io.buffer_data);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 17:07:51 +02:00
|
|
|
|
list.ClearList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
int DrawToolbarButton(char image_id, int x)
|
|
|
|
|
{
|
|
|
|
|
DrawOvalBorder(x, 5, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, sc.work_graph,
|
|
|
|
|
sc.work_graph,sc.work_graph, sc.work_dark);
|
|
|
|
|
img_draw stdcall(skin.image, x+1, 5+1, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, TOOLBAR_ICON_WIDTH*image_id, 0);
|
|
|
|
|
|
|
|
|
|
if (menu_id) && (menu_id == image_id) {
|
|
|
|
|
DrawRectangle3D(x+1, 6, TOOLBAR_ICON_WIDTH-1, TOOLBAR_ICON_HEIGHT-1, 0xCCCccc, 0xF8FCF8);
|
|
|
|
|
PutShadow(x+1, 6, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, true, 2);
|
|
|
|
|
}
|
|
|
|
|
DefineHiddenButton(x+1, 6, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, 10+image_id);
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-17 16:48:28 +01:00
|
|
|
|
void draw_window()
|
|
|
|
|
{
|
2020-04-21 22:49:38 +02:00
|
|
|
|
#define BUTTONS_GAP 5
|
|
|
|
|
#define BLOCKS_GAP 18
|
2018-04-03 14:45:08 +02:00
|
|
|
|
#define TOOLBAR_BUTTON_WIDTH 26
|
|
|
|
|
incn x;
|
2020-04-21 22:49:38 +02:00
|
|
|
|
int old_w;
|
2016-11-23 12:37:13 +01:00
|
|
|
|
DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
|
2015-12-17 16:48:28 +01:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2020-04-18 01:52:24 +02:00
|
|
|
|
sc.get();
|
2015-12-17 16:48:28 +01:00
|
|
|
|
if (Form.status_window>2) return;
|
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
if (Form.width < 340) { MoveSize(OLD,OLD,340,OLD); return; }
|
2015-12-17 16:48:28 +01:00
|
|
|
|
if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
|
|
|
|
|
|
2020-04-18 01:52:24 +02:00
|
|
|
|
DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work);
|
|
|
|
|
DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.work_graph);
|
2015-12-17 16:48:28 +01:00
|
|
|
|
|
2018-04-03 14:45:08 +02:00
|
|
|
|
x.n = 0;
|
|
|
|
|
DrawToolbarButton(OPEN_FILE, x.inc(8));
|
2018-10-15 00:02:13 +02:00
|
|
|
|
DrawToolbarButton(SHOW_FILE_PROPERTIES, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP));
|
|
|
|
|
|
|
|
|
|
DrawToolbarButton(MAGNIFY_MINUS, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP));
|
2018-10-02 22:13:25 +02:00
|
|
|
|
DrawToolbarButton(MAGNIFY_PLUS, x.inc(TOOLBAR_BUTTON_WIDTH - 1));
|
2018-10-15 00:02:13 +02:00
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
|
search_mx = DrawToolbarButton(SEARCH_BTN, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP));
|
|
|
|
|
charsets_mx = DrawToolbarButton(CHANGE_CHARSET, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP));
|
|
|
|
|
reopenin_mx = DrawToolbarButton(REOPEN_IN_APP, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP));
|
|
|
|
|
|
|
|
|
|
x.n = Form.cwidth - 34;
|
|
|
|
|
DrawToolbarButton(SHOW_INFO, x.n);
|
|
|
|
|
colscheme_mx = DrawToolbarButton(COLOR_SCHEME, x.inc(-TOOLBAR_BUTTON_WIDTH - BUTTONS_GAP));
|
|
|
|
|
|
2020-05-06 00:38:26 +02:00
|
|
|
|
if (search.draw(BTN_FIND_NEXT+10, BTN_FIND_CLOSE+10, Form.cheight - SEARCH_H)) {
|
2020-04-21 22:49:38 +02:00
|
|
|
|
DrawRectangle3D(search_mx+1, 6, TOOLBAR_ICON_WIDTH-1,
|
|
|
|
|
TOOLBAR_ICON_HEIGHT-1, 0xCCCccc, 0xF8FCF8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
old_w = list.w;
|
|
|
|
|
|
|
|
|
|
list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1,
|
|
|
|
|
Form.cheight-TOOLBAR_H-search.height(), math.round(kfont.size.pt * 1.4));
|
|
|
|
|
|
|
|
|
|
if ((Form.cwidth-scroll.size_x-1 == old_w) && (list.count)) {
|
2015-12-17 16:48:28 +01:00
|
|
|
|
DrawPage();
|
|
|
|
|
} else {
|
2020-04-21 22:49:38 +02:00
|
|
|
|
ParseAndPaint();
|
2018-10-15 00:02:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-17 16:48:28 +01:00
|
|
|
|
DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
|
2015-11-21 22:12:38 +01:00
|
|
|
|
}
|
2015-12-17 16:48:28 +01:00
|
|
|
|
|
|
|
|
|
void DrawPage()
|
|
|
|
|
{
|
2016-12-23 01:27:00 +01:00
|
|
|
|
kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w);
|
2018-05-22 14:04:44 +02:00
|
|
|
|
|
|
|
|
|
scroll.max_area = list.count;
|
|
|
|
|
scroll.cur_area = list.visible;
|
|
|
|
|
scroll.position = list.first;
|
|
|
|
|
scroll.all_redraw = 0;
|
|
|
|
|
scroll.start_x = list.x + list.w;
|
|
|
|
|
scroll.start_y = list.y;
|
|
|
|
|
scroll.size_y = list.h;
|
|
|
|
|
scrollbar_v_draw(#scroll);
|
2020-04-21 22:49:38 +02:00
|
|
|
|
}
|