Rev 6651 | Rev 6662 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6567 | leency | 1 | #ifndef AUTOBUILD |
2 | ?include "lang.h--" |
||
3 | #endif |
||
4 | |||
6653 | leency | 5 | #define MEMSIZE 4096*20 |
6567 | leency | 6 | #include "..\lib\mem.h" |
7 | #include "..\lib\strings.h" |
||
8 | #include "..\lib\list_box.h" |
||
9 | #include "..\lib\clipboard.h" |
||
10 | #include "..\lib\gui.h" |
||
11 | #include "..\lib\obj\box_lib.h" |
||
12 | |||
6651 | leency | 13 | #include "..\lib\patterns\select_list.h" |
6567 | leency | 14 | |
6651 | leency | 15 | |
6567 | leency | 16 | //===================================================// |
17 | // // |
||
18 | // DATA // |
||
19 | // // |
||
20 | //===================================================// |
||
21 | |||
6638 | leency | 22 | ?define WINDOW_HEADER "Clipboard Viewer v1.02" |
6567 | leency | 23 | ?define T_DELETE_LAST_SLOT "Delete last slot" |
24 | ?define T_DELETE_ALL_SLOTS "Delete all slots" |
||
25 | ?define T_RESET_BUFFER_LOCK "Reset the lock buffer" |
||
26 | ?define T_COLUMNS_TITLE "# | Data size | Data type | Contents" |
||
27 | ?define T_COLUMN_VIEW "View" |
||
28 | ?define T_VIEW_OPTIONS "TEXT HEX" |
||
29 | ?define DEFAULT_SAVE_PATH "/tmp0/1/clipview.tmp" |
||
30 | char *data_type[] = { "Text", "Image", "RAW", "Unknown" }; |
||
31 | |||
32 | enum { |
||
33 | BT_DELETE_LAST_SLOT = 10, |
||
34 | BT_DELETE_ALL_SLOTS, |
||
35 | BT_UNLOCK |
||
36 | }; |
||
37 | |||
38 | #define PANEL_TOP_H 20 |
||
39 | #define PANEL_BOTTOM_H 30 |
||
40 | #define LIST_PADDING 12 |
||
41 | |||
42 | proc_info Form; |
||
43 | |||
44 | Clipboard clipboard; |
||
45 | |||
46 | |||
47 | //===================================================// |
||
48 | // // |
||
49 | // CODE // |
||
50 | // // |
||
51 | //===================================================// |
||
52 | |||
53 | void main() |
||
54 | { |
||
55 | int id; |
||
56 | SetEventMask(0x27); |
||
57 | load_dll(boxlib, #box_lib_init,0); |
||
58 | loop() |
||
59 | { |
||
60 | WaitEventTimeout(10); |
||
61 | switch(EAX & 0xFF) |
||
62 | { |
||
63 | case evMouse: |
||
64 | if (!CheckActiveProcess(Form.ID)) break; |
||
6653 | leency | 65 | SelectList_ProcessMouse(); |
6567 | leency | 66 | break; |
67 | |||
68 | case evButton: |
||
69 | id=GetButtonID(); |
||
70 | if (id==1) ExitProcess(); |
||
71 | if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot(); |
||
72 | if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots(); |
||
73 | if (id==BT_UNLOCK) EventResetBufferLock(); |
||
74 | if (id>=100) && (id<300) EventOpenAsText(id-100); |
||
75 | if (id>=300) EventOpenAsHex(id-300); |
||
76 | break; |
||
77 | |||
78 | case evKey: |
||
79 | GetKeys(); |
||
6653 | leency | 80 | if (select_list.ProcessKey(key_scancode)) ClipViewSelectListDraw(); |
6567 | leency | 81 | break; |
82 | |||
83 | case evReDraw: |
||
84 | system.color.get(); |
||
85 | DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); |
||
86 | GetProcessInfo(#Form, SelfInfo); |
||
87 | IF (Form.status_window>=2) break; |
||
88 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } |
||
89 | if (Form.width < 570) { MoveSize(OLD,OLD,570,OLD); break; } |
||
6653 | leency | 90 | SelectList_Init( |
6651 | leency | 91 | LIST_PADDING, |
92 | LIST_PADDING+PANEL_TOP_H, |
||
93 | Form.cwidth-LIST_PADDING-LIST_PADDING-scroll1.size_x, |
||
94 | Form.cheight-PANEL_BOTTOM_H-PANEL_TOP_H-LIST_PADDING-LIST_PADDING, |
||
95 | true |
||
6653 | leency | 96 | ); |
6567 | leency | 97 | DrawWindowContent(); |
6653 | leency | 98 | ClipViewSelectListDraw(); |
6567 | leency | 99 | break; |
100 | |||
101 | default: |
||
6653 | leency | 102 | if (clipboard.GetSlotCount() > select_list.count) ClipViewSelectListDraw(); |
6567 | leency | 103 | break; |
104 | } |
||
105 | } |
||
106 | } |
||
107 | |||
108 | void DrawWindowContent() |
||
109 | { |
||
6651 | leency | 110 | int button_x = select_list.x; |
6567 | leency | 111 | DrawBar(0,0, Form.cwidth, PANEL_TOP_H, system.color.work); |
112 | DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, system.color.work); |
||
6651 | leency | 113 | DrawRectangle3D(select_list.x-2, select_list.y-2, select_list.w+3+scroll1.size_x, select_list.h+3, system.color.work_dark, system.color.work_light); |
114 | 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); |
||
115 | button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_LAST_SLOT, T_DELETE_LAST_SLOT); |
||
116 | button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_ALL_SLOTS, T_DELETE_ALL_SLOTS); |
||
117 | button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_UNLOCK, T_RESET_BUFFER_LOCK); |
||
118 | DrawRectangle(select_list.x-1, select_list.y-1, select_list.w+1+scroll1.size_x, select_list.h+1, system.color.work_graph); |
||
119 | WriteText(select_list.x+12, select_list.y - 23, select_list.font_type, system.color.work_text, T_COLUMNS_TITLE); |
||
120 | WriteText(select_list.x+select_list.w-68, select_list.y - 23, select_list.font_type, system.color.work_text, T_COLUMN_VIEW); |
||
6567 | leency | 121 | } |
122 | |||
6653 | leency | 123 | void SelectList_DrawLine(dword i) |
6567 | leency | 124 | { |
6651 | leency | 125 | int yyy, length, slot_data_type_number; |
126 | dword line_text[2048]; |
||
127 | dword size_kb; |
||
128 | dword text_color = 0; |
||
6567 | leency | 129 | |
6651 | leency | 130 | clipboard.GetSlotData(select_list.first + i); |
131 | yyy = i*select_list.item_h+select_list.y; |
||
132 | WriteText(select_list.x+12, yyy+select_list.text_y, select_list.font_type, text_color, itoa(select_list.first + i)); |
||
133 | //WriteText(select_list.x+44, yyy+select_list.text_y, select_list.font_type, text_color, itoa(clipboard.slot_data.size)); |
||
134 | size_kb = ConvertSizeToKb(clipboard.slot_data.size); |
||
135 | WriteText(select_list.x+44, yyy+select_list.text_y, select_list.font_type, text_color, size_kb); |
||
136 | slot_data_type_number = clipboard.slot_data.type; |
||
137 | WriteText(select_list.x+140, yyy+select_list.text_y, select_list.font_type, text_color, data_type[slot_data_type_number]); |
||
138 | WriteText(select_list.x+select_list.w - 88, yyy+select_list.text_y, select_list.font_type, 0x006597, T_VIEW_OPTIONS); |
||
139 | DefineButton(select_list.x+select_list.w - 95, yyy, 50, select_list.item_h, 100+i+BT_HIDE, NULL); |
||
140 | DefineButton(select_list.x+select_list.w - 95 + 51, yyy, 40, select_list.item_h, 300+i+BT_HIDE, NULL); |
||
6567 | leency | 141 | |
6651 | leency | 142 | length = select_list.w-236 - 95 / select_list.font_w - 2; |
143 | if (clipboard.slot_data.size-8 < length) length = clipboard.slot_data.size-8; |
||
144 | memmov(#line_text, clipboard.slot_data.content, length); |
||
145 | replace_char(#line_text, 0, 31, length); // 31 is a dot |
||
146 | WriteText(select_list.x+236, yyy+select_list.text_y, select_list.font_type, text_color, #line_text); |
||
6567 | leency | 147 | } |
148 | |||
6651 | leency | 149 | |
150 | |||
6638 | leency | 151 | replace_char(dword in_str, char from_char, to_char, int length) { |
152 | int i; |
||
153 | for (i=0; i |
||
154 | if (ESBYTE[in_str+i] == from_char) ESBYTE[in_str+i] = to_char; |
||
155 | } |
||
156 | ESBYTE[in_str+length]=0; |
||
157 | } |
||
6567 | leency | 158 | |
159 | int SaveSlotContents(int slot_id) { |
||
160 | clipboard.GetSlotData(slot_id); |
||
161 | EAX = WriteFile(clipboard.slot_data.size, clipboard.slot_data.content, DEFAULT_SAVE_PATH); |
||
162 | if (!EAX) |
||
163 | { |
||
164 | return true; |
||
165 | } |
||
166 | else { |
||
167 | notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E"); |
||
168 | return false; |
||
169 | } |
||
170 | } |
||
171 | |||
6653 | leency | 172 | void ClipViewSelectListDraw() { |
173 | select_list.count = clipboard.GetSlotCount(); |
||
174 | SelectList_Draw(); |
||
175 | } |
||
176 | |||
177 | void SelectList_LineChanged() { |
||
178 | return; |
||
179 | } |
||
180 | |||
6567 | leency | 181 | //===================================================// |
182 | // // |
||
183 | // EVENTS // |
||
184 | // // |
||
185 | //===================================================// |
||
186 | |||
187 | void EventDeleteLastSlot() |
||
188 | { |
||
6653 | leency | 189 | int i; |
190 | for (i=0; i |
||
191 | for (i=0; i |
||
6567 | leency | 192 | clipboard.DelLastSlot(); |
6653 | leency | 193 | ClipViewSelectListDraw(); |
6567 | leency | 194 | } |
195 | |||
196 | void EventDeleteAllSlots() |
||
197 | { |
||
198 | while (clipboard.GetSlotCount()) clipboard.DelLastSlot(); |
||
6653 | leency | 199 | ClipViewSelectListDraw(); |
6567 | leency | 200 | } |
201 | |||
202 | void EventResetBufferLock() { |
||
203 | clipboard.ResetBlockingBuffer(); |
||
6653 | leency | 204 | ClipViewSelectListDraw(); |
6567 | leency | 205 | } |
206 | |||
207 | void EventOpenAsText(int slot_id) { |
||
208 | if (SaveSlotContents(slot_id)) RunProgram("/sys/tinypad", DEFAULT_SAVE_PATH); |
||
209 | } |
||
210 | |||
211 | void EventOpenAsHex(int slot_id) { |
||
212 | if (SaveSlotContents(slot_id)) RunProgram("/sys/develop/heed", DEFAULT_SAVE_PATH); |
||
213 | } |
||
214 | |||
215 | stop:>>>300)> |