Rev 8860 | Rev 8936 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8860 | Rev 8933 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef AUTOBUILD |
1 | #define ENTRY_POINT #main |
2 | ?include "lang.h--" |
- | |
3 | #endif |
- | |
Line 4... | Line 2... | ||
4 | 2 | ||
5 | #define MEMSIZE 4096*20 |
- | |
- | 3 | #define MEMSIZE 4096*20 |
|
6 | #include "..\lib\mem.h" |
4 | |
7 | #include "..\lib\strings.h" |
- | |
8 | #include "..\lib\list_box.h" |
5 | #include "..\lib\strings.h" |
9 | #include "..\lib\clipboard.h" |
6 | #include "..\lib\clipboard.h" |
10 | #include "..\lib\gui.h" |
7 | #include "..\lib\gui.h" |
11 | #include "..\lib\obj\box_lib.h" |
- | |
12 | - | ||
13 | #include "..\lib\patterns\select_list.h" |
- | |
Line 14... | Line 8... | ||
14 | 8 | #include "..\lib\fs.h" |
|
15 | 9 | ||
16 | //===================================================// |
10 | //===================================================// |
17 | // // |
11 | // // |
18 | // DATA // |
12 | // DATA // |
Line 19... | Line -... | ||
19 | // // |
- | |
20 | //===================================================// |
- | |
21 | - | ||
22 | ?define WINDOW_HEADER "Clipboard Viewer" |
- | |
23 | ?define T_DELETE_LAST_SLOT "Delete last slot" |
13 | // // |
24 | ?define T_DELETE_ALL_SLOTS "Delete all slots" |
14 | //===================================================// |
25 | ?define T_RESET_BUFFER_LOCK "Reset the lock buffer" |
- | |
26 | ?define T_COLUMNS_TITLE "# | Data size | Data type | Contents" |
15 | |
27 | ?define T_COLUMN_VIEW "| View" |
16 | ?define T_COLUMNS_TITLE "# | Data size | Data type | Contents" |
Line 28... | Line 17... | ||
28 | ?define T_VIEW_OPTIONS "TEXT HEX" |
17 | ?define T_COLUMN_VIEW "| View" |
29 | ?define DEFAULT_SAVE_PATH "/tmp0/1/clipview.tmp" |
18 | ?define DEFAULT_SAVE_PATH "/tmp0/1/clipview.tmp" |
30 | char *data_type[] = { "Text", "Image", "RAW", "Unknown" }; |
19 | char *data_type[] = { "Text", "Image", "RAW", "Unknown" }; |
31 | 20 | ||
- | 21 | enum { |
|
- | 22 | BT_DELETE_LAST = 10, |
|
32 | enum { |
23 | BT_DELETE_ALL, |
Line 33... | Line 24... | ||
33 | BT_DELETE_LAST_SLOT = 10, |
24 | BT_UNLOCK, |
- | 25 | BT_LIST_LEFT, |
|
- | 26 | BT_LIST_RIGHT |
|
34 | BT_DELETE_ALL_SLOTS, |
27 | }; |
35 | BT_UNLOCK |
28 | |
- | 29 | #define PANEL_BOTTOM_H 35 |
|
Line 36... | Line 30... | ||
36 | }; |
30 | #define GAP 5 |
Line -... | Line 31... | ||
- | 31 | #define LIST_Y 32 |
|
- | 32 | #define PANEL_TOP_H LIST_Y-2 |
|
- | 33 | #define LINE_H 20 |
|
- | 34 | #define TEXT_Y LINE_H - 14 / 2 |
|
- | 35 | ||
- | 36 | proc_info Form; |
|
- | 37 | ||
37 | 38 | struct LIST { |
|
38 | #define PANEL_TOP_H 20 |
39 | int w,h; |
39 | #define PANEL_BOTTOM_H 30 |
40 | int count; |
40 | #define LIST_PADDING 12 |
41 | int first; |
41 | 42 | int visible; |
|
Line 42... | Line 43... | ||
42 | proc_info Form; |
43 | } list = 0; |
43 | 44 | ||
44 | //===================================================// |
45 | //===================================================// |
45 | // // |
46 | // // |
46 | // CODE // |
- | |
47 | // // |
- | |
48 | //===================================================// |
47 | // CODE // |
49 | 48 | // // |
|
50 | void main() |
- | |
51 | { |
- | |
52 | int id; |
- | |
53 | @SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
- | |
54 | #define NO_DLL_INIT |
49 | //===================================================// |
55 | load_dll(boxlib, #box_lib_init,0); |
50 | |
56 | loop() switch(@WaitEventTimeout(10)) |
51 | void main() |
57 | { |
52 | { |
58 | case evMouse: |
53 | mem_init(); |
59 | SelectList_ProcessMouse(); |
54 | @SetEventMask(EVM_REDRAW + EVM_BUTTON); |
60 | break; |
- | |
61 | 55 | loop() switch(@WaitEventTimeout(10)) |
|
62 | case evButton: |
56 | { |
- | 57 | case evButton: |
|
- | 58 | @GetButtonID(); |
|
63 | id = @GetButtonID(); |
59 | switch(EAX) { |
64 | if (id==1) ExitProcess(); |
60 | case 1: |
- | 61 | ExitProcess(); |
|
- | 62 | case BT_DELETE_LAST: |
|
- | 63 | EventDeleteLastSlot(); |
|
- | 64 | break; |
|
65 | if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot(); |
65 | case BT_DELETE_ALL: |
66 | if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots(); |
66 | EventDeleteAllSlots(); |
- | 67 | break; |
|
- | 68 | case BT_UNLOCK: |
|
- | 69 | EventResetBufferLock(); |
|
- | 70 | break; |
|
- | 71 | case BT_LIST_LEFT: |
|
- | 72 | list.first -= list.visible; |
|
- | 73 | if (list.first <= 0) list.first = 0; |
|
- | 74 | ClipViewSelectListDraw(); |
|
67 | if (id==BT_UNLOCK) EventResetBufferLock(); |
75 | break; |
68 | if (id>=100) && (id<300) EventOpenAsText(id-100); |
76 | case BT_LIST_RIGHT: |
Line 69... | Line 77... | ||
69 | if (id>=300) EventOpenAsHex(id-300); |
77 | if (list.first + list.visible < list.count) list.first += list.visible; |
70 | break; |
78 | ClipViewSelectListDraw(); |
71 | 79 | break; |
|
72 | case evKey: |
80 | default: |
73 | if (select_list.ProcessKey(@GetKeyScancode())) { |
81 | if (EAX>=300) EventOpenAsHex(EAX-300); |
74 | ClipViewSelectListDraw(); |
82 | else EventOpenAsText(EAX-100); |
75 | } |
83 | } |
76 | break; |
- | |
77 | - | ||
78 | case evReDraw: |
- | |
79 | sc.get(); |
- | |
80 | DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); |
- | |
81 | GetProcessInfo(#Form, SelfInfo); |
- | |
82 | IF (Form.status_window>=2) break; |
- | |
83 | IF (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } |
84 | break; |
84 | IF (Form.width < 570) { MoveSize(OLD,OLD,570,OLD); break; } |
85 | |
Line 85... | Line 86... | ||
85 | SelectList_Init( |
86 | case evReDraw: |
86 | LIST_PADDING, |
87 | sc.get(); |
87 | LIST_PADDING+PANEL_TOP_H, |
- | |
88 | Form.cwidth-LIST_PADDING-LIST_PADDING-scroll1.size_x, |
88 | DefineAndDrawWindow(GetScreenWidth()-600/2,80,600,400,0x73,NULL,"Clipboard Viewer",NULL); |
89 | Form.cheight-PANEL_BOTTOM_H-PANEL_TOP_H-LIST_PADDING-LIST_PADDING, |
89 | GetProcessInfo(#Form, SelfInfo); |
Line 90... | Line 90... | ||
90 | true |
90 | IF (Form.status_window>=2) break; |
91 | ); |
91 | IF (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } |
- | 92 | IF (Form.width < 570) { MoveSize(OLD,OLD,570,OLD); break; } |
|
- | 93 | DrawWindowContent(); |
|
92 | DrawWindowContent(); |
94 | break; |
- | 95 | ||
- | 96 | default: |
|
93 | break; |
97 | if (Clipboard__GetSlotCount() > list.count) ClipViewSelectListDraw(); |
94 | 98 | } |
|
95 | default: |
99 | } |
- | 100 | ||
96 | if (Clipboard__GetSlotCount() > select_list.count) ClipViewSelectListDraw(); |
101 | void DrawWindowContent() |
- | 102 | { |
|
97 | break; |
103 | list.w = Form.cwidth-GAP-GAP; |
- | 104 | list.h = Form.cheight-PANEL_BOTTOM_H-LIST_Y-GAP; |
|
- | 105 | list.visible = list.h / LINE_H; |
|
- | 106 | if (list.first > list.count) list.first = list.count - list.visible; |
|
- | 107 | ||
- | 108 | DrawBar(0,0, Form.cwidth, PANEL_TOP_H, sc.work); |
|
98 | } |
109 | DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, sc.work); |
- | 110 | DrawWideRectangle(GAP-GAP, LIST_Y-GAP, GAP*2+list.w, GAP*2+list.h, GAP-2, sc.work); |
|
99 | } |
111 | |
100 | 112 | DefineButton(GAP, list.h + LIST_Y + 8, 110, 25, BT_DELETE_LAST, sc.button); |
|
101 | void DrawWindowContent() |
113 | $inc edx |
102 | { |
114 | $add ebx, 130 << 16 //BT_DELETE_ALL |
103 | int button_x = select_list.x; |
115 | $int 64 |
Line 104... | Line 116... | ||
104 | DrawBar(0,0, Form.cwidth, PANEL_TOP_H, sc.work); |
116 | $inc edx |
Line 123... | Line 135... | ||
123 | dword content_offset; |
135 | dword content_offset; |
124 | } cdata; |
136 | } cdata; |
Line 125... | Line 137... | ||
125 | 137 | ||
126 | void SelectList_DrawLine(dword i) |
138 | void SelectList_DrawLine(dword i) |
127 | { |
139 | { |
128 | int yyy, length, slot_data_type_number; |
- | |
Line -... | Line 140... | ||
- | 140 | int yyy, slot_data_type_number; |
|
- | 141 | ||
- | 142 | yyy = i*LINE_H+LIST_Y; |
|
- | 143 | DrawBar(GAP, yyy, list.w, LINE_H, -i%2 * 0x0E0E0E + 0xF1F1f1); |
|
- | 144 | ||
- | 145 | if (list.first + i >= list.count) { |
|
- | 146 | return; |
|
129 | dword line_text[2048]; |
147 | } |
130 | 148 | ||
131 | slot_data = Clipboard__GetSlotData(select_list.first + i); |
149 | slot_data = Clipboard__GetSlotData(list.first + i); |
132 | cdata.size = ESDWORD[slot_data]; |
150 | cdata.size = ESDWORD[slot_data]; |
133 | cdata.type = ESDWORD[slot_data+4]; |
151 | cdata.type = ESDWORD[slot_data+4]; |
134 | if (cdata.type==SLOT_DATA_TYPE_TEXT) || (cdata.type==SLOT_DATA_TYPE_TEXT_BLOCK) |
152 | if (cdata.type==SLOT_DATA_TYPE_TEXT) || (cdata.type==SLOT_DATA_TYPE_TEXT_BLOCK) |
135 | cdata.content_offset = 12; |
153 | cdata.content_offset = 12; |
136 | else |
154 | else |
Line 137... | Line -... | ||
137 | cdata.content_offset = 8; |
- | |
138 | cdata.content = slot_data + cdata.content_offset; |
- | |
139 | 155 | cdata.content_offset = 8; |
|
140 | yyy = i*select_list.item_h+select_list.y; |
156 | cdata.content = slot_data + cdata.content_offset; |
141 | DrawBar(select_list.x+1, yyy, select_list.w-1, select_list.item_h, -i%2 * 0x0E0E0E + 0xF1F1f1); |
157 | |
142 | WriteText(select_list.x+12, yyy+select_list.text_y, 0x90, 0x000000, itoa(select_list.first + i)); |
158 | WriteText(GAP+12, yyy+TEXT_Y, 0x90, 0x000000, itoa(list.first + i)); |
143 | EDX = ConvertSizeToKb(cdata.size); |
159 | EDX = ConvertSizeToKb(cdata.size); |
144 | WriteText(select_list.x+44, yyy+select_list.text_y, 0x90, 0x000000, EDX); |
160 | WriteText(GAP+44, yyy+TEXT_Y, 0x90, 0x000000, EDX); |
145 | slot_data_type_number = cdata.type; |
161 | slot_data_type_number = cdata.type; |
146 | WriteText(select_list.x+140, yyy+select_list.text_y, 0x90, 0x000000, data_type[slot_data_type_number]); |
162 | WriteText(GAP+140, yyy+TEXT_Y, 0x90, 0x000000, data_type[slot_data_type_number]); |
147 | WriteText(select_list.x+select_list.w - 88, yyy+select_list.text_y, 0x90, 0x006597, T_VIEW_OPTIONS); |
163 | WriteText(GAP+list.w - 88, yyy+TEXT_Y, 0x90, 0x006597, "TEXT HEX"); |
148 | DefineButton(select_list.x+select_list.w - 95, yyy, 50, select_list.item_h, 100+i+BT_HIDE, NULL); |
164 | DefineButton(GAP+list.w - 98, yyy, 50, LINE_H, 100+i+BT_HIDE, NULL); |
149 | DefineButton(select_list.x+select_list.w - 95 + 51, yyy, 40, select_list.item_h, 300+i+BT_HIDE, NULL); |
165 | DefineButton(GAP+list.w - 95 + 51, yyy, 40, LINE_H, 300+i+BT_HIDE, NULL); |
150 | - | ||
151 | length = select_list.w-236 - 95 / select_list.font_w - 2; |
- | |
152 | if (cdata.size - cdata.content_offset < length) length = cdata.size - cdata.content_offset; |
166 | |
153 | strlcpy(#line_text, cdata.content, length); |
167 | ESI = list.w - 345 / 8; |
Line 154... | Line 168... | ||
154 | replace_char(#line_text, 0, 31, length); // 31 is a dot |
168 | if (cdata.size - cdata.content_offset < ESI) ESI = cdata.size - cdata.content_offset; |
155 | WriteText(select_list.x+236, yyy+select_list.text_y, 0x90, 0x000000, #line_text); |
169 | WriteText(GAP+236, yyy+TEXT_Y, 0x30, 0x000000, cdata.content); |
156 | } |
170 | } |
Line 162... | Line 176... | ||
162 | notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E"); |
176 | notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E"); |
163 | return false; |
177 | return false; |
164 | } |
178 | } |
165 | } |
179 | } |
Line 166... | Line 180... | ||
166 | 180 | ||
- | 181 | void ClipViewSelectListDraw() |
|
- | 182 | { |
|
- | 183 | int i, list_last; |
|
167 | void ClipViewSelectListDraw() { |
184 | |
- | 185 | list.count = Clipboard__GetSlotCount(); |
|
- | 186 | ||
- | 187 | if (list.count > list.visible) list_last = list.visible; else list_last = list.count; |
|
- | 188 | ||
- | 189 | for (i=0; i |
|
- | 190 | ||
- | 191 | DrawBar(GAP,i*LINE_H+LIST_Y, list.w, -i*LINE_H+ list.h, 0xFFFfff); |
|
- | 192 | if (!list.count) WriteText(list.w / 2 + GAP - 60, |
|
- | 193 | list.h / 2 - 8 + LIST_Y, 0x90, 0x999999, "No data to show"); |
|
- | 194 | ||
- | 195 | if (list.count > list.visible) { |
|
- | 196 | param[0] = list.first / list.visible + '0'; |
|
- | 197 | DefineButton(Form.cwidth-84-GAP, list.h + LIST_Y + 8, 25, 25, BT_LIST_LEFT, sc.button); //BT_LEFT |
|
- | 198 | $inc edx |
|
- | 199 | $add ebx, 57 << 16 //BT_RIGHT |
|
- | 200 | $int 64 |
|
- | 201 | WriteText(Form.cwidth-84-GAP+10, list.h + LIST_Y + 14, 0x90, sc.button_text, "< >"); |
|
168 | select_list.count = Clipboard__GetSlotCount(); |
202 | $add ebx, 28 << 16 |
- | 203 | $mov edx, #param; |
|
- | 204 | $mov edi, sc.work_text |
|
- | 205 | $add ecx, 0x40 << 24 |
|
- | 206 | $int 64 |
|
169 | SelectList_Draw(); |
207 | } |
Line 170... | Line 208... | ||
170 | } |
208 | } |
- | 209 | ||
- | 210 | void SelectList_DrawBorder() { |
|
- | 211 | DrawRectangle3D(GAP-2, LIST_Y-2, |
|
- | 212 | list.w+3, list.h+3, |
|
171 | 213 | sc.work_dark, sc.work_light); |
|
- | 214 | DrawRectangle3D(GAP-1, LIST_Y-1, |
|
172 | void SelectList_LineChanged() { |
215 | list.w+1, list.h+1, |
Line 173... | Line 216... | ||
173 | return; |
216 | sc.work_graph, sc.work_graph); |
174 | } |
217 | } |
175 | 218 | ||
Line 180... | Line 223... | ||
180 | //===================================================// |
223 | //===================================================// |
Line 181... | Line 224... | ||
181 | 224 | ||
182 | void EventDeleteLastSlot() |
225 | void EventDeleteLastSlot() |
183 | { |
226 | { |
184 | int i; |
227 | int i; |
185 | for (i=0; i |
228 | for (i=0; i |
- | 229 | DeleteButton(list.first + i + 100); |
|
- | 230 | $add edx, 200 |
|
- | 231 | $int 64 |
|
186 | for (i=0; i |
232 | } |
187 | Clipboard__DeleteLastSlot(); |
233 | Clipboard__DeleteLastSlot(); |
188 | ClipViewSelectListDraw(); |
234 | DrawWindowContent(); |
Line 189... | Line 235... | ||
189 | } |
235 | } |
190 | 236 | ||
191 | void EventDeleteAllSlots() |
237 | void EventDeleteAllSlots() |
192 | { |
238 | { |
193 | while (Clipboard__GetSlotCount()) Clipboard__DeleteLastSlot(); |
239 | while (Clipboard__GetSlotCount()) Clipboard__DeleteLastSlot(); |
Line 194... | Line 240... | ||
194 | ClipViewSelectListDraw(); |
240 | DrawWindowContent(); |
195 | } |
241 | } |
196 | 242 | ||
197 | void EventResetBufferLock() { |
243 | void EventResetBufferLock() { |
Line 198... | Line 244... | ||
198 | Clipboard__ResetBlockingBuffer(); |
244 | Clipboard__ResetBlockingBuffer(); |
199 | ClipViewSelectListDraw(); |
245 | DrawWindowContent(); |
200 | } |
246 | } |