Mercurial > hg > openttd
comparison src/textbuf.cpp @ 20147:09c103c821b1 draft
(svn r25091) -Codechange: Call keycodes by their name.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 17 Mar 2013 13:05:18 +0000 |
parents | b39f0ea0d0cc |
children | 115d14632c22 |
comparison
equal
deleted
inserted
replaced
20146:b39f0ea0d0cc | 20147:09c103c821b1 |
---|---|
96 } | 96 } |
97 | 97 |
98 /** | 98 /** |
99 * Delete a character from a textbuffer, either with 'Delete' or 'Backspace' | 99 * Delete a character from a textbuffer, either with 'Delete' or 'Backspace' |
100 * The character is delete from the position the caret is at | 100 * The character is delete from the position the caret is at |
101 * @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE | 101 * @param keycode Type of deletion, either WKC_BACKSPACE or WKC_DELETE |
102 * @return Return true on successful change of Textbuf, or false otherwise | 102 * @return Return true on successful change of Textbuf, or false otherwise |
103 */ | 103 */ |
104 bool Textbuf::DeleteChar(int delmode) | 104 bool Textbuf::DeleteChar(uint16 keycode) |
105 { | 105 { |
106 if (delmode == WKC_BACKSPACE || delmode == WKC_DELETE) { | 106 if (keycode == WKC_BACKSPACE || keycode == WKC_DELETE) { |
107 bool backspace = delmode == WKC_BACKSPACE; | 107 bool backspace = keycode == WKC_BACKSPACE; |
108 if (CanDelChar(backspace)) { | 108 if (CanDelChar(backspace)) { |
109 this->DelChar(backspace); | 109 this->DelChar(backspace); |
110 return true; | 110 return true; |
111 } | 111 } |
112 return false; | 112 return false; |
113 } | 113 } |
114 | 114 |
115 if (delmode == (WKC_CTRL | WKC_BACKSPACE) || delmode == (WKC_CTRL | WKC_DELETE)) { | 115 if (keycode == (WKC_CTRL | WKC_BACKSPACE) || keycode == (WKC_CTRL | WKC_DELETE)) { |
116 bool backspace = delmode == (WKC_CTRL | WKC_BACKSPACE); | 116 bool backspace = keycode == (WKC_CTRL | WKC_BACKSPACE); |
117 | 117 |
118 if (!CanDelChar(backspace)) return false; | 118 if (!CanDelChar(backspace)) return false; |
119 WChar c = this->GetNextDelChar(backspace); | 119 WChar c = this->GetNextDelChar(backspace); |
120 | 120 |
121 /* Backspace: Delete left whitespaces. | 121 /* Backspace: Delete left whitespaces. |
274 } | 274 } |
275 | 275 |
276 /** | 276 /** |
277 * Handle text navigation with arrow keys left/right. | 277 * Handle text navigation with arrow keys left/right. |
278 * This defines where the caret will blink and the next character interaction will occur | 278 * This defines where the caret will blink and the next character interaction will occur |
279 * @param navmode Direction in which navigation occurs (WKC_CTRL |) WKC_LEFT, (WKC_CTRL |) WKC_RIGHT, WKC_END, WKC_HOME | 279 * @param keycode Direction in which navigation occurs (WKC_CTRL |) WKC_LEFT, (WKC_CTRL |) WKC_RIGHT, WKC_END, WKC_HOME |
280 * @return Return true on successful change of Textbuf, or false otherwise | 280 * @return Return true on successful change of Textbuf, or false otherwise |
281 */ | 281 */ |
282 bool Textbuf::MovePos(int navmode) | 282 bool Textbuf::MovePos(uint16 keycode) |
283 { | 283 { |
284 switch (navmode) { | 284 switch (keycode) { |
285 case WKC_LEFT: | 285 case WKC_LEFT: |
286 if (this->CanMoveCaretLeft()) { | 286 if (this->CanMoveCaretLeft()) { |
287 this->MoveCaretLeft(); | 287 this->MoveCaretLeft(); |
288 return true; | 288 return true; |
289 } | 289 } |