1 //this file is part of notepad++
2 //Copyright (C)2003 Don HO ( donho@altern.org )
3 //
4 //This program is free software; you can redistribute it and/or
5 //modify it under the terms of the GNU General Public License
6 //as published by the Free Software Foundation; either
7 //version 2 of the License, or (at your option) any later version.
8 //
9 //This program is distributed in the hope that it will be useful,
10 //but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //GNU General Public License for more details.
13 //
14 //You should have received a copy of the GNU General Public License
15 //along with this program; if not, write to the Free Software
16 //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 module npp_converter.conversionpanel;
18 
19 
20 private static import core.stdc.string;
21 private static import core.stdc.wchar_;
22 private static import core.sys.windows.basetsd;
23 private static import core.sys.windows.winbase;
24 private static import core.sys.windows.windef;
25 private static import core.sys.windows.wingdi;
26 private static import core.sys.windows.winnt;
27 private static import core.sys.windows.winuser;
28 private static import std.ascii;
29 private static import std.conv;
30 private static import npp_api.pluginfunc.scintilla_msg;
31 private static import npp_api.pluginfunc.string;
32 private static import npp_api.powereditor.wincontrols.dockingwnd.dockingdlginterface;
33 private static import npp_converter.plugindefinition;
34 private static import npp_converter.resource;
35 
36 enum BCKGRD_COLOR = core.sys.windows.wingdi.RGB(255, 102, 102);
37 enum TXT_COLOR = core.sys.windows.wingdi.RGB(255, 255, 255);
38 enum CF_NPPTEXTLEN = npp_api.pluginfunc..string.c_wstring!("Notepad++ Binary Text Length"w);
39 
40 npp_converter.conversionpanel.ConversionPanel _conversionPanel;
41 
42 class ConversionPanel : npp_api.powereditor.wincontrols.dockingwnd.dockingdlginterface.DockingDlgInterface
43 {
44 public:
45 	pure nothrow @safe @nogc
46 	this()
47 
48 		do
49 		{
50 			this.lock = false;
51 			super(npp_converter.resource.IDD_CONVERSION_PANEL);
52 		}
53 
54 	nothrow @nogc
55 	override void display(bool toShow = true, bool enhancedPositioningCheckWhenShowing = false)
56 
57 		do
58 		{
59 			super.display(toShow);
60 
61 			if (toShow) {
62 				core.sys.windows.winuser.SetFocus(core.sys.windows.winuser.GetDlgItem(this._hSelf, npp_converter.resource.ID_ASCII_EDIT));
63 			}
64 		}
65 
66 	pure nothrow @safe @nogc
67 	void setParent(core.sys.windows.windef.HWND parent2set)
68 
69 		do
70 		{
71 			this._hParent = parent2set;
72 		}
73 
74 	nothrow @nogc
75 	void resetExcept(int exceptID)
76 
77 		do
78 		{
79 			if (exceptID != npp_converter.resource.ID_ASCII_EDIT) {
80 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_ASCII_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&("\0"w[0])));
81 			}
82 
83 			if (exceptID != npp_converter.resource.ID_DEC_EDIT) {
84 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_DEC_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&("\0"w[0])));
85 			}
86 
87 			if (exceptID != npp_converter.resource.ID_HEX_EDIT) {
88 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_HEX_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&("\0"w[0])));
89 			}
90 
91 			if (exceptID != npp_converter.resource.ID_OCT_EDIT) {
92 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_OCT_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&("\0"w[0])));
93 			}
94 
95 			if (exceptID != npp_converter.resource.ID_BIN_EDIT) {
96 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_BIN_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&("\0"w[0])));
97 			}
98 		}
99 
100 	nothrow @nogc
101 	void setValueFrom(int id)
102 
103 		do
104 		{
105 			enum int inStrSize = 256;
106 			this.lock = true;
107 			core.sys.windows.winnt.WCHAR[inStrSize] intStr;
108 			core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, id, core.sys.windows.winuser.WM_GETTEXT, inStrSize, cast(core.sys.windows.windef.LPARAM)(&(intStr[0])));
109 
110 			this.resetExcept(id);
111 
112 			if (intStr[0] == '\0') {
113 				this.lock = false;
114 
115 				return;
116 			}
117 
118 			if (!this.qualified(&(intStr[0]), id)) {
119 				this.lock = false;
120 				int len = core.sys.windows.winbase.lstrlenW(&(intStr[0]));
121 				intStr[len - 1] = '\0';
122 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, id, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&(intStr[0])));
123 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, id, core.sys.windows.winuser.EM_SETSEL, len - 1, len - 1);
124 
125 				return;
126 			}
127 
128 			int base = 10;
129 
130 			switch (id) {
131 				case npp_converter.resource.ID_ASCII_EDIT:
132 					base = 0;
133 
134 					break;
135 
136 				case npp_converter.resource.ID_DEC_EDIT:
137 					base = 10;
138 
139 					break;
140 
141 				case npp_converter.resource.ID_HEX_EDIT:
142 					base = 16;
143 
144 					break;
145 
146 				case npp_converter.resource.ID_OCT_EDIT:
147 					base = 8;
148 
149 					break;
150 
151 				case npp_converter.resource.ID_BIN_EDIT:
152 					base = 2;
153 
154 					break;
155 
156 				default:
157 					break;
158 			}
159 
160 			ulong v = 0;
161 
162 			if (!base) {
163 				v = intStr[0];
164 			} else {
165 				v = core.stdc.wchar_.wcstoul(&(intStr[0]), core.sys.windows.windef.NULL, base);
166 			}
167 
168 			this.setValueExcept(id, v);
169 			this.lock = false;
170 		}
171 
172 	nothrow @nogc
173 	void setValueExcept(int exceptID, ulong value)
174 
175 		do
176 		{
177 			enum strLen = 1024;
178 			core.sys.windows.winnt.WCHAR[strLen] str2Display = '\0';
179 
180 			if (exceptID != npp_converter.resource.ID_ASCII_EDIT) {
181 				if (value <= 255) {
182 					core.sys.windows.winnt.WCHAR[2] ascii2Display;
183 					ascii2Display[0] = cast(core.sys.windows.winnt.WCHAR)(value);
184 					ascii2Display[1] = '\0';
185 					core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_ASCII_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&ascii2Display[0]));
186 					core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_ASCII_INFO_STATIC, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&(this.getAsciiInfo(cast(ubyte)(value))[0])));
187 				} else {
188 					core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_ASCII_INFO_STATIC, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&("\0"w[0])));
189 				}
190 			} else {
191 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_ASCII_INFO_STATIC, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&(this.getAsciiInfo(cast(ubyte)(value))[0])));
192 			}
193 
194 			if (exceptID != npp_converter.resource.ID_DEC_EDIT) {
195 				core.stdc.wchar_.swprintf(&(str2Display[0]), strLen, &(npp_api.pluginfunc..string.c_wstring!("%d"w)[0]), cast(size_t)(value));
196 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_DEC_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&(str2Display[0])));
197 			}
198 
199 			if (exceptID != npp_converter.resource.ID_HEX_EDIT) {
200 				core.stdc.wchar_.swprintf(&(str2Display[0]), strLen, &(npp_api.pluginfunc..string.c_wstring!("%X"w)[0]), cast(size_t)(value));
201 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_HEX_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&(str2Display[0])));
202 			}
203 
204 			if (exceptID != npp_converter.resource.ID_OCT_EDIT) {
205 				core.stdc.wchar_.swprintf(&(str2Display[0]), strLen, &(npp_api.pluginfunc..string.c_wstring!("%o"w)[0]), cast(size_t)(value));
206 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_OCT_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&(str2Display[0])));
207 			}
208 
209 			if (exceptID != npp_converter.resource.ID_BIN_EDIT) {
210 				wchar[1234] str2DisplayA = '\0';
211 				auto temp = std.conv.toChars!(2, wchar, std.ascii.LetterCase.lower)(value);
212 
213 				for (size_t i = 0; i < temp.length; i++) {
214 					str2DisplayA[i] = temp[i];
215 				}
216 
217 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_BIN_EDIT, core.sys.windows.winuser.WM_SETTEXT, 0, cast(core.sys.windows.windef.LPARAM)(&(str2DisplayA[0])));
218 			}
219 		}
220 
221 	nothrow @nogc
222 	bool qualified(core.sys.windows.winnt.WCHAR* str, int id)
223 
224 		do
225 		{
226 			for (int i = 0 ; i < core.sys.windows.winbase.lstrlenW(str) ; i++) {
227 				if (id == npp_converter.resource.ID_ASCII_EDIT) {
228 					//Only one character, Accept all
229 				} else if (id == npp_converter.resource.ID_HEX_EDIT) {
230 		  			if (!(((str[i] >= '0') && (str[i] <= '9')) || ((str[i] >= 'A') && (str[i] <= 'F')) || ((str[i] >= 'a') && (str[i] <= 'f')))) {
231 
232 						return false;
233 					}
234 				} else if (id == npp_converter.resource.ID_DEC_EDIT) {
235 					if (!((str[i] >= '0') && (str[i] <= '9'))) {
236 
237 						return false;
238 					}
239 				} else if (id == npp_converter.resource.ID_OCT_EDIT) {
240 					if (!((str[i] >= '0') && (str[i] <= '7'))) {
241 
242 						return false;
243 					}
244 				} else if (id == npp_converter.resource.ID_BIN_EDIT) {
245 					if (!((str[i] == '0') || (str[i] == '1'))) {
246 
247 						return false;
248 					}
249 				}
250 			}
251 
252 			return true;
253 		}
254 
255 	pure nothrow @safe @nogc
256 	wstring getAsciiInfo(ubyte value)
257 
258 		out(result)
259 		{
260 			if (result.length != 0) {
261 				assert(result[$ - 1] == '\0');
262 			}
263 		}
264 
265 		do
266 		{
267 			switch (value) {
268 				case 0:
269 					return npp_api.pluginfunc..string.c_wstring!("NULL"w);
270 
271 				case 1:
272 					return npp_api.pluginfunc..string.c_wstring!("SOH"w);
273 
274 				case 2:
275 					return npp_api.pluginfunc..string.c_wstring!("STX"w);
276 
277 				case 3:
278 					return npp_api.pluginfunc..string.c_wstring!("ETX"w);
279 
280 				case 4:
281 					return npp_api.pluginfunc..string.c_wstring!("EOT"w);
282 
283 				case 5:
284 					return npp_api.pluginfunc..string.c_wstring!("ENQ"w);
285 
286 				case 6:
287 					return npp_api.pluginfunc..string.c_wstring!("ACK"w);
288 
289 				case 7:
290 					return npp_api.pluginfunc..string.c_wstring!("BEL"w);
291 
292 				case 8:
293 					return npp_api.pluginfunc..string.c_wstring!("BS"w);
294 
295 				case 9:
296 					return npp_api.pluginfunc..string.c_wstring!("TAB"w);
297 
298 				case 10:
299 					return npp_api.pluginfunc..string.c_wstring!("LF"w);
300 
301 				case 11:
302 					return npp_api.pluginfunc..string.c_wstring!("VT"w);
303 
304 				case 12:
305 					return npp_api.pluginfunc..string.c_wstring!("FF"w);
306 
307 				case 13:
308 					return npp_api.pluginfunc..string.c_wstring!("CR"w);
309 
310 				case 14:
311 					return npp_api.pluginfunc..string.c_wstring!("SO"w);
312 
313 				case 15:
314 					return npp_api.pluginfunc..string.c_wstring!("SI"w);
315 
316 				case 16:
317 					return npp_api.pluginfunc..string.c_wstring!("DLE"w);
318 
319 				case 17:
320 					return npp_api.pluginfunc..string.c_wstring!("DC1"w);
321 
322 				case 18:
323 					return npp_api.pluginfunc..string.c_wstring!("DC2"w);
324 
325 				case 19:
326 					return npp_api.pluginfunc..string.c_wstring!("DC3"w);
327 
328 				case 20:
329 					return npp_api.pluginfunc..string.c_wstring!("DC4"w);
330 
331 				case 21:
332 					return npp_api.pluginfunc..string.c_wstring!("NAK"w);
333 
334 				case 22:
335 					return npp_api.pluginfunc..string.c_wstring!("SYN"w);
336 
337 				case 23:
338 					return npp_api.pluginfunc..string.c_wstring!("ETB"w);
339 
340 				case 24:
341 					return npp_api.pluginfunc..string.c_wstring!("CAN"w);
342 
343 				case 25:
344 					return npp_api.pluginfunc..string.c_wstring!("EM"w);
345 
346 				case 26:
347 					return npp_api.pluginfunc..string.c_wstring!("SUB"w);
348 
349 				case 27:
350 					return npp_api.pluginfunc..string.c_wstring!("ESC"w);
351 
352 				case 28:
353 					return npp_api.pluginfunc..string.c_wstring!("FS"w);
354 
355 				case 29:
356 					return npp_api.pluginfunc..string.c_wstring!("GS"w);
357 
358 				case 30:
359 					return npp_api.pluginfunc..string.c_wstring!("RS"w);
360 
361 				case 31:
362 					return npp_api.pluginfunc..string.c_wstring!("US"w);
363 
364 				case 32:
365 					return npp_api.pluginfunc..string.c_wstring!("Space"w);
366 
367 				case 127:
368 					return npp_api.pluginfunc..string.c_wstring!("DEL"w);
369 					/*
370 					case 0:
371 						return npp_api.pluginfunc.string.c_wstring!("NULL"w);
372 					case 0:
373 						return npp_api.pluginfunc.string.c_wstring!("NULL"w);
374 					case 0:
375 						return npp_api.pluginfunc.string.c_wstring!("NULL"w);
376 					case 0:
377 						return npp_api.pluginfunc.string.c_wstring!("NULL"w);
378 					case 0:
379 						return npp_api.pluginfunc.string.c_wstring!("NULL"w);
380 					*/
381 
382 				default:
383 					break;
384 			}
385 
386 			return "\0"w;
387 		}
388 
389 	nothrow @nogc
390 	void insertToNppFrom(int id)
391 
392 		do
393 		{
394 			enum inStrSize = 256;
395 			char[inStrSize] intStr;
396 			core.sys.windows.winuser.SendDlgItemMessageA(this._hSelf, id, core.sys.windows.winuser.WM_GETTEXT, inStrSize, cast(core.sys.windows.windef.LPARAM)(&(intStr[0])));
397 			core.sys.windows.windef.HWND hCurrScintilla = npp_converter.plugindefinition.getCurrentScintillaHandle();
398 			npp_api.pluginfunc.scintilla_msg.send_SCI_REPLACESEL(hCurrScintilla, &(intStr[0]));
399 		}
400 
401 	nothrow @nogc
402 	int getAsciiUcharFromDec()
403 
404 		do
405 		{
406 			enum inStrSize = 256;
407 			core.sys.windows.winnt.WCHAR[inStrSize] intStr;
408 			core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_DEC_EDIT, core.sys.windows.winuser.WM_GETTEXT, inStrSize, cast(core.sys.windows.windef.LPARAM)(&(intStr[0])));
409 			int v = core.stdc.wchar_.wcstoul(&(intStr[0]), core.sys.windows.windef.NULL, 10);
410 
411 			if (v > 255) {
412 				return -1;
413 			}
414 
415 			return v;
416 		}
417 
418 	nothrow @nogc
419 	void copyToClipboardFrom(int id)
420 
421 		do
422 		{
423 			enum intStrMaxSize = 256;
424 			char[intStrMaxSize] intStr;
425 			size_t intStrLen = 0;
426 
427 			if (id == npp_converter.resource.ID_ASCII_EDIT) {
428 				int v = this.getAsciiUcharFromDec();
429 
430 				if (v == -1) {
431 					return;
432 				}
433 
434 				intStr[0] = cast(char)(v);
435 				intStr[1] = '\0';
436 				intStrLen = 1;
437 			} else {
438 				core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, id, core.sys.windows.winuser.WM_GETTEXT, intStrMaxSize, cast(core.sys.windows.windef.LPARAM)(&(intStr[0])));
439 				intStrLen = core.stdc..string.strlen(&(intStr[0]));
440 			}
441 
442 			// Open the clipboard, and empty it.
443 			if (!core.sys.windows.winuser.OpenClipboard(core.sys.windows.windef.NULL)) {
444 				return;
445 			}
446 
447 			core.sys.windows.winuser.EmptyClipboard();
448 
449 			// Allocate a global memory object for the text.
450 			core.sys.windows.windef.HGLOBAL hglbCopy = core.sys.windows.winbase.GlobalAlloc(core.sys.windows.winbase.GMEM_MOVEABLE, (intStrLen + 1) * ubyte.sizeof);
451 
452 			if (hglbCopy == core.sys.windows.windef.NULL) {
453 				core.sys.windows.winuser.CloseClipboard();
454 
455 				return;
456 			}
457 
458 			// Lock the handle and copy the text to the buffer.
459 			ubyte* lpucharCopy = cast(ubyte*)(core.sys.windows.winbase.GlobalLock(hglbCopy));
460 			core.stdc..string.memcpy(lpucharCopy, &(intStr[0]), intStrLen * ubyte.sizeof);
461 
462 			// null character
463 			lpucharCopy[intStrLen] = '\0';
464 
465 			core.sys.windows.winbase.GlobalUnlock(hglbCopy);
466 
467 			// Place the handle on the clipboard.
468 			core.sys.windows.winuser.SetClipboardData(core.sys.windows.winuser.CF_TEXT, hglbCopy);
469 
470 			// Allocate a global memory object for the text length.
471 			core.sys.windows.windef.HGLOBAL hglbLenCopy = core.sys.windows.winbase.GlobalAlloc(core.sys.windows.winbase.GMEM_MOVEABLE, ulong.sizeof);
472 
473 			if (hglbLenCopy == core.sys.windows.windef.NULL) {
474 				core.sys.windows.winuser.CloseClipboard();
475 
476 				return;
477 			}
478 
479 			// Lock the handle and copy the text to the buffer.
480 			ulong* lpLenCopy = cast(ulong*)(core.sys.windows.winbase.GlobalLock(hglbLenCopy));
481 			*lpLenCopy = cast(ulong)(intStrLen);
482 
483 			core.sys.windows.winbase.GlobalUnlock(hglbLenCopy);
484 
485 			// Place the handle on the clipboard.
486 			core.sys.windows.windef.UINT f = core.sys.windows.winuser.RegisterClipboardFormatW(&(CF_NPPTEXTLEN[0]));
487 			core.sys.windows.winuser.SetClipboardData(f, hglbLenCopy);
488 
489 			core.sys.windows.winuser.CloseClipboard();
490 
491 		}
492 
493 protected:
494 	extern (Windows)
495 	nothrow @nogc
496 	override core.sys.windows.basetsd.INT_PTR run_dlgProc(core.sys.windows.windef.UINT message, core.sys.windows.windef.WPARAM wParam, core.sys.windows.windef.LPARAM lParam)
497 
498 		do
499 		{
500 			switch (message) {
501 				case core.sys.windows.winuser.WM_INITDIALOG:
502 					core.sys.windows.winuser.SendDlgItemMessageW(this._hSelf, npp_converter.resource.ID_ASCII_EDIT, core.sys.windows.winuser.EM_LIMITTEXT, 1, 0);
503 
504 					return core.sys.windows.windef.TRUE;
505 
506 				case core.sys.windows.winuser.WM_COMMAND:
507 					switch (wParam) {
508 						case npp_converter.resource.ID_ASCII_INSERT_BUTTON:
509 							int v = this.getAsciiUcharFromDec();
510 
511 							if (v != -1) {
512 								char[2] charStr;
513 								charStr[0] = cast(char)(v);
514 								charStr[1] = '\0';
515 								core.sys.windows.windef.HWND hCurrScintilla = npp_converter.plugindefinition.getCurrentScintillaHandle();
516 								npp_api.pluginfunc.scintilla_msg.send_SCI_REPLACESEL(hCurrScintilla, &("\0"[0]));
517 								npp_api.pluginfunc.scintilla_msg.send_SCI_ADDTEXT(hCurrScintilla, 1, &(charStr[0]));
518 							}
519 
520 							return core.sys.windows.windef.TRUE;
521 
522 						case npp_converter.resource.ID_DEC_INSERT_BUTTON:
523 							this.insertToNppFrom(npp_converter.resource.ID_DEC_EDIT);
524 
525 							return core.sys.windows.windef.TRUE;
526 
527 						case npp_converter.resource.ID_HEX_INSERT_BUTTON:
528 							this.insertToNppFrom(npp_converter.resource.ID_HEX_EDIT);
529 
530 							return core.sys.windows.windef.TRUE;
531 
532 						case npp_converter.resource.ID_BIN_INSERT_BUTTON:
533 							this.insertToNppFrom(npp_converter.resource.ID_BIN_EDIT);
534 
535 							return core.sys.windows.windef.TRUE;
536 
537 						case npp_converter.resource.ID_OCT_INSERT_BUTTON:
538 							this.insertToNppFrom(npp_converter.resource.ID_OCT_EDIT);
539 
540 							return core.sys.windows.windef.TRUE;
541 
542 						case npp_converter.resource.ID_ASCII_BUTTON:
543 							this.copyToClipboardFrom(npp_converter.resource.ID_ASCII_EDIT);
544 
545 							return core.sys.windows.windef.TRUE;
546 
547 						case npp_converter.resource.ID_DEC_BUTTON:
548 							this.copyToClipboardFrom(npp_converter.resource.ID_DEC_EDIT);
549 
550 							return core.sys.windows.windef.TRUE;
551 
552 						case npp_converter.resource.ID_HEX_BUTTON:
553 							this.copyToClipboardFrom(npp_converter.resource.ID_HEX_EDIT);
554 
555 							return core.sys.windows.windef.TRUE;
556 
557 						case npp_converter.resource.ID_BIN_BUTTON:
558 							this.copyToClipboardFrom(npp_converter.resource.ID_BIN_EDIT);
559 
560 							return core.sys.windows.windef.TRUE;
561 
562 						case npp_converter.resource.ID_OCT_BUTTON:
563 							this.copyToClipboardFrom(npp_converter.resource.ID_OCT_EDIT);
564 
565 							return core.sys.windows.windef.TRUE;
566 
567 						default:
568 							break;
569 					}
570 
571 					if (core.sys.windows.windef.HIWORD(wParam) == core.sys.windows.winuser.EN_CHANGE) {
572 						switch (core.sys.windows.windef.LOWORD(wParam)) {
573 							case npp_converter.resource.ID_ASCII_EDIT:
574 							case npp_converter.resource.ID_DEC_EDIT:
575 							case npp_converter.resource.ID_HEX_EDIT:
576 							case npp_converter.resource.ID_BIN_EDIT:
577 							case npp_converter.resource.ID_OCT_EDIT:
578 								if (!this.lock) {
579 									this.setValueFrom(cast(int)(core.sys.windows.windef.LOWORD(wParam)));
580 								}
581 
582 								return core.sys.windows.windef.TRUE;
583 
584 							default:
585 								break;
586 						}
587 					}
588 
589 					return core.sys.windows.windef.FALSE;
590 
591 				default:
592 					return super.run_dlgProc(message, wParam, lParam);
593 			}
594 		}
595 
596 private:
597 	bool lock;
598 
599 	nothrow @nogc
600 	int getLine()
601 
602 		do
603 		{
604 			core.sys.windows.windef.BOOL isSuccessful;
605 			int line = core.sys.windows.winuser.GetDlgItemInt(this._hSelf, npp_converter.resource.ID_ASCII_EDIT, &isSuccessful, core.sys.windows.windef.FALSE);
606 
607 			return (isSuccessful) ? (line) : (-1);
608 		}
609 }