Rev 6653 | Rev 7037 | 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(); |
98 | break; |
||
99 | |||
100 | default: |
||
6653 | leency | 101 | if (clipboard.GetSlotCount() > select_list.count) ClipViewSelectListDraw(); |
6567 | leency | 102 | break; |
103 | } |
||
104 | } |
||
105 | } |
||
106 | |||
107 | void DrawWindowContent() |
||
108 | { |
||
6651 | leency | 109 | int button_x = select_list.x; |
6567 | leency | 110 | DrawBar(0,0, Form.cwidth, PANEL_TOP_H, system.color.work); |
111 | DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, system.color.work); |
||
6651 | leency | 112 | 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); |
113 | button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_LAST_SLOT, T_DELETE_LAST_SLOT); |
||
114 | button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_ALL_SLOTS, T_DELETE_ALL_SLOTS); |
||
115 | button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_UNLOCK, T_RESET_BUFFER_LOCK); |
||
116 | WriteText(select_list.x+12, select_list.y - 23, select_list.font_type, system.color.work_text, T_COLUMNS_TITLE); |
||
117 | WriteText(select_list.x+select_list.w-68, select_list.y - 23, select_list.font_type, system.color.work_text, T_COLUMN_VIEW); |
||
6662 | leency | 118 | ClipViewSelectListDraw(); |
119 | SelectList_DrawBorder(); |
||
6567 | leency | 120 | } |
121 | |||
6653 | leency | 122 | void SelectList_DrawLine(dword i) |
6567 | leency | 123 | { |
6651 | leency | 124 | int yyy, length, slot_data_type_number; |
125 | dword line_text[2048]; |
||
126 | dword size_kb; |
||
127 | dword text_color = 0; |
||
6567 | leency | 128 | |
6651 | leency | 129 | clipboard.GetSlotData(select_list.first + i); |
130 | yyy = i*select_list.item_h+select_list.y; |
||
131 | WriteText(select_list.x+12, yyy+select_list.text_y, select_list.font_type, text_color, itoa(select_list.first + i)); |
||
132 | //WriteText(select_list.x+44, yyy+select_list.text_y, select_list.font_type, text_color, itoa(clipboard.slot_data.size)); |
||
133 | size_kb = ConvertSizeToKb(clipboard.slot_data.size); |
||
134 | WriteText(select_list.x+44, yyy+select_list.text_y, select_list.font_type, text_color, size_kb); |
||
135 | slot_data_type_number = clipboard.slot_data.type; |
||
136 | WriteText(select_list.x+140, yyy+select_list.text_y, select_list.font_type, text_color, data_type[slot_data_type_number]); |
||
137 | WriteText(select_list.x+select_list.w - 88, yyy+select_list.text_y, select_list.font_type, 0x006597, T_VIEW_OPTIONS); |
||
138 | DefineButton(select_list.x+select_list.w - 95, yyy, 50, select_list.item_h, 100+i+BT_HIDE, NULL); |
||
139 | DefineButton(select_list.x+select_list.w - 95 + 51, yyy, 40, select_list.item_h, 300+i+BT_HIDE, NULL); |
||
6567 | leency | 140 | |
6651 | leency | 141 | length = select_list.w-236 - 95 / select_list.font_w - 2; |
142 | if (clipboard.slot_data.size-8 < length) length = clipboard.slot_data.size-8; |
||
143 | memmov(#line_text, clipboard.slot_data.content, length); |
||
144 | replace_char(#line_text, 0, 31, length); // 31 is a dot |
||
145 | WriteText(select_list.x+236, yyy+select_list.text_y, select_list.font_type, text_color, #line_text); |
||
6567 | leency | 146 | } |
147 | |||
6651 | leency | 148 | |
149 | |||
6638 | leency | 150 | replace_char(dword in_str, char from_char, to_char, int length) { |
151 | int i; |
||
152 | for (i=0; i |
||
153 | if (ESBYTE[in_str+i] == from_char) ESBYTE[in_str+i] = to_char; |
||
154 | } |
||
155 | ESBYTE[in_str+length]=0; |
||
156 | } |
||
6567 | leency | 157 | |
158 | int SaveSlotContents(int slot_id) { |
||
159 | clipboard.GetSlotData(slot_id); |
||
160 | EAX = WriteFile(clipboard.slot_data.size, clipboard.slot_data.content, DEFAULT_SAVE_PATH); |
||
161 | if (!EAX) |
||
162 | { |
||
163 | return true; |
||
164 | } |
||
165 | else { |
||
166 | notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E"); |
||
167 | return false; |
||
168 | } |
||
169 | } |
||
170 | |||
6653 | leency | 171 | void ClipViewSelectListDraw() { |
172 | select_list.count = clipboard.GetSlotCount(); |
||
173 | SelectList_Draw(); |
||
174 | } |
||
175 | |||
176 | void SelectList_LineChanged() { |
||
177 | return; |
||
178 | } |
||
179 | |||
6567 | leency | 180 | //===================================================// |
181 | // // |
||
182 | // EVENTS // |
||
183 | // // |
||
184 | //===================================================// |
||
185 | |||
186 | void EventDeleteLastSlot() |
||
187 | { |
||
6653 | leency | 188 | int i; |
189 | for (i=0; i |
||
190 | for (i=0; i |
||
6567 | leency | 191 | clipboard.DelLastSlot(); |
6653 | leency | 192 | ClipViewSelectListDraw(); |
6567 | leency | 193 | } |
194 | |||
195 | void EventDeleteAllSlots() |
||
196 | { |
||
197 | while (clipboard.GetSlotCount()) clipboard.DelLastSlot(); |
||
6653 | leency | 198 | ClipViewSelectListDraw(); |
6567 | leency | 199 | } |
200 | |||
201 | void EventResetBufferLock() { |
||
202 | clipboard.ResetBlockingBuffer(); |
||
6653 | leency | 203 | ClipViewSelectListDraw(); |
6567 | leency | 204 | } |
205 | |||
206 | void EventOpenAsText(int slot_id) { |
||
207 | if (SaveSlotContents(slot_id)) RunProgram("/sys/tinypad", DEFAULT_SAVE_PATH); |
||
208 | } |
||
209 | |||
210 | void EventOpenAsHex(int slot_id) { |
||
211 | if (SaveSlotContents(slot_id)) RunProgram("/sys/develop/heed", DEFAULT_SAVE_PATH); |
||
212 | } |
||
213 | |||
214 | stop:>>>300)> |