2016-10-05 16:12:39 +03:00
|
|
|
#ifndef AUTOBUILD
|
|
|
|
?include "lang.h--"
|
|
|
|
#endif
|
|
|
|
|
2016-11-02 17:30:45 +03:00
|
|
|
#define MEMSIZE 4096*20
|
2016-10-05 16:12:39 +03:00
|
|
|
#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"
|
|
|
|
|
2016-11-02 15:19:15 +03:00
|
|
|
#include "..\lib\patterns\select_list.h"
|
|
|
|
|
2016-10-05 16:12:39 +03:00
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// DATA //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
2016-10-31 01:47:57 +03:00
|
|
|
?define WINDOW_HEADER "Clipboard Viewer v1.02"
|
2016-10-05 16:12:39 +03:00
|
|
|
?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
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PANEL_TOP_H 20
|
|
|
|
#define PANEL_BOTTOM_H 30
|
|
|
|
#define LIST_PADDING 12
|
|
|
|
|
|
|
|
proc_info Form;
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// CODE //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
int id;
|
2017-10-01 14:57:00 +03:00
|
|
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
2016-10-05 16:12:39 +03:00
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
|
|
|
loop()
|
|
|
|
{
|
|
|
|
WaitEventTimeout(10);
|
|
|
|
switch(EAX & 0xFF)
|
|
|
|
{
|
|
|
|
case evMouse:
|
2016-11-02 17:30:45 +03:00
|
|
|
SelectList_ProcessMouse();
|
2016-10-05 16:12:39 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case evButton:
|
2017-10-01 14:57:00 +03:00
|
|
|
id = GetButtonID();
|
2016-10-05 16:12:39 +03:00
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case evKey:
|
|
|
|
GetKeys();
|
2016-11-02 17:30:45 +03:00
|
|
|
if (select_list.ProcessKey(key_scancode)) ClipViewSelectListDraw();
|
2016-10-05 16:12:39 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case evReDraw:
|
|
|
|
system.color.get();
|
|
|
|
DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0);
|
|
|
|
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; }
|
2016-11-02 17:30:45 +03:00
|
|
|
SelectList_Init(
|
2016-11-02 15:19:15 +03:00
|
|
|
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
|
2016-11-02 17:30:45 +03:00
|
|
|
);
|
2016-10-05 16:12:39 +03:00
|
|
|
DrawWindowContent();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2017-10-01 14:57:00 +03:00
|
|
|
if (Clipboard__GetSlotCount() > select_list.count) ClipViewSelectListDraw();
|
2016-10-05 16:12:39 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawWindowContent()
|
|
|
|
{
|
2016-11-02 15:19:15 +03:00
|
|
|
int button_x = select_list.x;
|
2016-10-05 16:12:39 +03:00
|
|
|
DrawBar(0,0, Form.cwidth, PANEL_TOP_H, system.color.work);
|
|
|
|
DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, system.color.work);
|
2016-11-02 15:19:15 +03:00
|
|
|
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, system.color.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, select_list.font_type, system.color.work_text, T_COLUMNS_TITLE);
|
|
|
|
WriteText(select_list.x+select_list.w-68, select_list.y - 23, select_list.font_type, system.color.work_text, T_COLUMN_VIEW);
|
2016-11-03 15:41:15 +03:00
|
|
|
ClipViewSelectListDraw();
|
|
|
|
SelectList_DrawBorder();
|
2016-10-05 16:12:39 +03:00
|
|
|
}
|
|
|
|
|
2017-10-01 14:57:00 +03:00
|
|
|
dword slot_data;
|
|
|
|
struct clipboard_data
|
|
|
|
{
|
|
|
|
dword size;
|
|
|
|
dword type;
|
|
|
|
dword encoding;
|
|
|
|
dword content;
|
|
|
|
dword content_offset;
|
|
|
|
} cdata;
|
|
|
|
|
2016-11-02 17:30:45 +03:00
|
|
|
void SelectList_DrawLine(dword i)
|
2016-10-05 16:12:39 +03:00
|
|
|
{
|
2016-11-02 15:19:15 +03:00
|
|
|
int yyy, length, slot_data_type_number;
|
|
|
|
dword line_text[2048];
|
|
|
|
dword size_kb;
|
|
|
|
dword text_color = 0;
|
2016-10-05 16:12:39 +03:00
|
|
|
|
2017-10-01 14:57:00 +03:00
|
|
|
slot_data = Clipboard__GetSlotData(select_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)
|
|
|
|
cdata.content_offset = 12;
|
|
|
|
else
|
|
|
|
cdata.content_offset = 8;
|
|
|
|
cdata.content = slot_data + cdata.content_offset;
|
|
|
|
|
2016-11-02 15:19:15 +03:00
|
|
|
yyy = i*select_list.item_h+select_list.y;
|
|
|
|
WriteText(select_list.x+12, yyy+select_list.text_y, select_list.font_type, text_color, itoa(select_list.first + i));
|
2017-10-01 14:57:00 +03:00
|
|
|
size_kb = ConvertSizeToKb(cdata.size);
|
2016-11-02 15:19:15 +03:00
|
|
|
WriteText(select_list.x+44, yyy+select_list.text_y, select_list.font_type, text_color, size_kb);
|
2017-10-01 14:57:00 +03:00
|
|
|
slot_data_type_number = cdata.type;
|
2016-11-02 15:19:15 +03:00
|
|
|
WriteText(select_list.x+140, yyy+select_list.text_y, select_list.font_type, text_color, data_type[slot_data_type_number]);
|
|
|
|
WriteText(select_list.x+select_list.w - 88, yyy+select_list.text_y, select_list.font_type, 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);
|
|
|
|
|
|
|
|
length = select_list.w-236 - 95 / select_list.font_w - 2;
|
2017-10-01 14:57:00 +03:00
|
|
|
if (cdata.size - cdata.content_offset < length) length = cdata.size - cdata.content_offset;
|
|
|
|
memmov(#line_text, cdata.content, length);
|
2016-11-02 15:19:15 +03:00
|
|
|
replace_char(#line_text, 0, 31, length); // 31 is a dot
|
|
|
|
WriteText(select_list.x+236, yyy+select_list.text_y, select_list.font_type, text_color, #line_text);
|
|
|
|
}
|
2016-10-05 16:12:39 +03:00
|
|
|
|
2017-10-01 14:57:00 +03:00
|
|
|
int SaveSlotContents(dword size, off) {
|
2018-04-16 01:44:36 +03:00
|
|
|
EAX = CreateFile(size, off, DEFAULT_SAVE_PATH);
|
2016-10-05 16:12:39 +03:00
|
|
|
if (!EAX)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 17:30:45 +03:00
|
|
|
void ClipViewSelectListDraw() {
|
2017-10-01 14:57:00 +03:00
|
|
|
select_list.count = Clipboard__GetSlotCount();
|
2016-11-02 17:30:45 +03:00
|
|
|
SelectList_Draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SelectList_LineChanged() {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-05 16:12:39 +03:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// EVENTS //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
void EventDeleteLastSlot()
|
|
|
|
{
|
2016-11-02 17:30:45 +03:00
|
|
|
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);
|
2017-10-01 14:57:00 +03:00
|
|
|
Clipboard__DeleteLastSlot();
|
2016-11-02 17:30:45 +03:00
|
|
|
ClipViewSelectListDraw();
|
2016-10-05 16:12:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventDeleteAllSlots()
|
|
|
|
{
|
2017-10-01 14:57:00 +03:00
|
|
|
while (Clipboard__GetSlotCount()) Clipboard__DeleteLastSlot();
|
2016-11-02 17:30:45 +03:00
|
|
|
ClipViewSelectListDraw();
|
2016-10-05 16:12:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventResetBufferLock() {
|
2017-10-01 14:57:00 +03:00
|
|
|
Clipboard__ResetBlockingBuffer();
|
2016-11-02 17:30:45 +03:00
|
|
|
ClipViewSelectListDraw();
|
2016-10-05 16:12:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventOpenAsText(int slot_id) {
|
2017-10-01 14:57:00 +03:00
|
|
|
slot_data = Clipboard__GetSlotData(slot_id);
|
|
|
|
cdata.size = ESDWORD[slot_data]-12;
|
|
|
|
cdata.content = slot_data+12;
|
|
|
|
if (SaveSlotContents(cdata.size, cdata.content)) RunProgram("/sys/tinypad", DEFAULT_SAVE_PATH);
|
2016-10-05 16:12:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventOpenAsHex(int slot_id) {
|
2017-10-01 14:57:00 +03:00
|
|
|
slot_data = Clipboard__GetSlotData(slot_id);
|
|
|
|
cdata.size = ESDWORD[slot_data];
|
|
|
|
cdata.content = slot_data;
|
|
|
|
if (SaveSlotContents(cdata.size, cdata.content)) RunProgram("/sys/develop/heed", DEFAULT_SAVE_PATH);
|
2016-10-05 16:12:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
stop:
|