Little rearrangement for readibility

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6758 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2009-04-13 07:32:01 +00:00
parent ead9c2ce24
commit c2e3704d6b
4 changed files with 66 additions and 27 deletions
+2
View File
@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.3.0 CHANGES IN FLTK 1.3.0
- Added OS X cursor control to Fl_Input (STR #2169)
- Fixed control key keycodes with modifiers on OS X
- Avoiding crashes for recursive common dialogs (this does not - Avoiding crashes for recursive common dialogs (this does not
fix the issue at hand yet) (STR #1986, 2150) fix the issue at hand yet) (STR #1986, 2150)
- Added menu shortcut alignment for OS X - Added menu shortcut alignment for OS X
+4 -2
View File
@@ -197,8 +197,10 @@ Fl_File_Input::handle(int event) // I - Event
case FL_MOVE : case FL_MOVE :
case FL_ENTER : case FL_ENTER :
if (active_r()) { if (active_r()) {
if (Fl::event_y() < (y() + DIR_HEIGHT)) window()->cursor(FL_CURSOR_DEFAULT); if (Fl::event_y() < (y() + DIR_HEIGHT))
else window()->cursor(FL_CURSOR_INSERT); window()->cursor(FL_CURSOR_DEFAULT);
else
window()->cursor(FL_CURSOR_INSERT);
} }
return 1; return 1;
+54 -18
View File
@@ -150,21 +150,57 @@ int Fl_Input::handle_key() {
else ascii = ctrl('D'); else ascii = ctrl('D');
break; break;
case FL_Left: case FL_Left:
ascii = ctrl('B'); break; ascii = ctrl('B');
#ifdef __APPLE__
if (Fl::event_state() & (FL_META|FL_CTRL) ) ascii = ctrl('A');
// FIXME backward one word is missing (Alt-Left)
#endif // __APPLE__
break;
case FL_Right: case FL_Right:
ascii = ctrl('F'); break; ascii = ctrl('F');
#ifdef __APPLE__
if (Fl::event_state() & (FL_META|FL_CTRL) ) ascii = ctrl('E');
// FIXME advance one word is missing (Alt-Right)
#endif // __APPLE__
break;
case FL_Page_Up: case FL_Page_Up:
fl_font(textfont(),textsize()); //ensure current font is set to ours fl_font(textfont(),textsize()); //ensure current font is set to ours
repeat_num=h()/fl_height(); // number of lines to scroll repeat_num=h()/fl_height(); // number of lines to scroll
if (!repeat_num) repeat_num=1; if (!repeat_num) repeat_num=1;
case FL_Up: case FL_Up:
ascii = ctrl('P'); break; ascii = ctrl('P');
#ifdef __APPLE__
if (Fl::event_state() & (FL_META) ) {
shift_position(0);
return 1;
}
if (Fl::event_state() & (FL_ALT) ) {
if (line_start(position())==position() && position()>0)
return shift_position(line_start(position()-1)) + NORMAL_INPUT_MOVE;
else
return shift_position(line_start(position())) + NORMAL_INPUT_MOVE;
}
#endif // __APPLE__
break;
case FL_Page_Down: case FL_Page_Down:
fl_font(textfont(),textsize()); fl_font(textfont(),textsize());
repeat_num=h()/fl_height(); repeat_num=h()/fl_height();
if (!repeat_num) repeat_num=1; if (!repeat_num) repeat_num=1;
case FL_Down: case FL_Down:
ascii = ctrl('N'); break; ascii = ctrl('N');
#ifdef __APPLE__
if (Fl::event_state() & (FL_META) ) {
shift_position(size());
return 1;
}
if (Fl::event_state() & (FL_ALT) ) {
if (line_end(position())==position() && position()<size())
return shift_position(line_end(position()+1)) + NORMAL_INPUT_MOVE;
else
return shift_position(line_end(position())) + NORMAL_INPUT_MOVE;
}
#endif // __APPLE__
break;
case FL_Home: case FL_Home:
if (Fl::event_state() & FL_CTRL) { if (Fl::event_state() & FL_CTRL) {
shift_position(0); shift_position(0);
@@ -212,13 +248,13 @@ int Fl_Input::handle_key() {
int i; int i;
switch (ascii) { switch (ascii) {
case ctrl('A'): case ctrl('A'): // go to the beginning of the current line
return shift_position(line_start(position())) + NORMAL_INPUT_MOVE; return shift_position(line_start(position())) + NORMAL_INPUT_MOVE;
case ctrl('B'): case ctrl('B'): // go one character backward
return shift_position(position()-1) + NORMAL_INPUT_MOVE; return shift_position(position()-1) + NORMAL_INPUT_MOVE;
case ctrl('C'): // copy case ctrl('C'): // copy
return copy(1); return copy(1);
case ctrl('D'): case ctrl('D'): // cut the next character
case ctrl('?'): case ctrl('?'):
if (readonly()) { if (readonly()) {
fl_beep(); fl_beep();
@@ -226,11 +262,11 @@ int Fl_Input::handle_key() {
} }
if (mark() != position()) return cut(); if (mark() != position()) return cut();
else return cut(1); else return cut(1);
case ctrl('E'): case ctrl('E'): // go to the end of the line
return shift_position(line_end(position())) + NORMAL_INPUT_MOVE; return shift_position(line_end(position())) + NORMAL_INPUT_MOVE;
case ctrl('F'): case ctrl('F'): // go to the next character
return shift_position(position()+1) + NORMAL_INPUT_MOVE; return shift_position(position()+1) + NORMAL_INPUT_MOVE;
case ctrl('H'): case ctrl('H'): // cut the previous character
if (readonly()) { if (readonly()) {
fl_beep(); fl_beep();
return 1; return 1;
@@ -238,7 +274,7 @@ int Fl_Input::handle_key() {
if (mark() != position()) cut(); if (mark() != position()) cut();
else cut(-1); else cut(-1);
return 1; return 1;
case ctrl('K'): case ctrl('K'): // cut to the end of the line
if (readonly()) { if (readonly()) {
fl_beep(); fl_beep();
return 1; return 1;
@@ -248,7 +284,7 @@ int Fl_Input::handle_key() {
if (i == position() && i < size()) i++; if (i == position() && i < size()) i++;
cut(position(), i); cut(position(), i);
return copy_cuts(); return copy_cuts();
case ctrl('N'): case ctrl('N'): // go down one line
i = position(); i = position();
if (line_end(i) >= size()) return NORMAL_INPUT_MOVE; if (line_end(i) >= size()) return NORMAL_INPUT_MOVE;
while (repeat_num--) { while (repeat_num--) {
@@ -258,7 +294,7 @@ int Fl_Input::handle_key() {
} }
shift_up_down_position(i); shift_up_down_position(i);
return 1; return 1;
case ctrl('P'): case ctrl('P'): // go up one line
i = position(); i = position();
if (!line_start(i)) return NORMAL_INPUT_MOVE; if (!line_start(i)) return NORMAL_INPUT_MOVE;
while(repeat_num--) { while(repeat_num--) {
@@ -268,13 +304,13 @@ int Fl_Input::handle_key() {
} }
shift_up_down_position(line_start(i)); shift_up_down_position(line_start(i));
return 1; return 1;
case ctrl('U'): case ctrl('U'): // clear the whole document?
if (readonly()) { if (readonly()) {
fl_beep(); fl_beep();
return 1; return 1;
} }
return cut(0, size()); return cut(0, size());
case ctrl('V'): case ctrl('V'): // paste text
case ctrl('Y'): case ctrl('Y'):
if (readonly()) { if (readonly()) {
fl_beep(); fl_beep();
@@ -282,7 +318,7 @@ int Fl_Input::handle_key() {
} }
Fl::paste(*this, 1); Fl::paste(*this, 1);
return 1; return 1;
case ctrl('X'): case ctrl('X'): // cut the selected text
case ctrl('W'): case ctrl('W'):
if (readonly()) { if (readonly()) {
fl_beep(); fl_beep();
@@ -290,14 +326,14 @@ int Fl_Input::handle_key() {
} }
copy(1); copy(1);
return cut(); return cut();
case ctrl('Z'): case ctrl('Z'): // undo
case ctrl('_'): case ctrl('_'):
if (readonly()) { if (readonly()) {
fl_beep(); fl_beep();
return 1; return 1;
} }
return undo(); return undo();
case ctrl('I'): case ctrl('I'): // insert literal
case ctrl('J'): case ctrl('J'):
case ctrl('L'): case ctrl('L'):
case ctrl('M'): case ctrl('M'):
+6 -7
View File
@@ -1304,7 +1304,7 @@ pascal OSStatus carbonKeyboardHandler(
// In this mode, there seem to be no key-down codes // In this mode, there seem to be no key-down codes
// printf("%08x %08x %08x\n", keyCode, mods, key); // printf("%08x %08x %08x\n", keyCode, mods, key);
maskedKeyCode = keyCode & 0x7f; maskedKeyCode = keyCode & 0x7f;
/* output a human readable event identifier for debugging */ /* output a human readable event identifier for debugging
const char *ev = ""; const char *ev = "";
switch (kind) { switch (kind) {
case kEventRawKeyDown: ev = "kEventRawKeyDown"; break; case kEventRawKeyDown: ev = "kEventRawKeyDown"; break;
@@ -1313,8 +1313,8 @@ pascal OSStatus carbonKeyboardHandler(
case kEventRawKeyModifiersChanged: ev = "kEventRawKeyModifiersChanged"; break; case kEventRawKeyModifiersChanged: ev = "kEventRawKeyModifiersChanged"; break;
default: ev = "unknown"; default: ev = "unknown";
} }
// printf("%08x %08x %08x '%c' %s \n", mods, keyCode, key, key, ev); printf("%08x %08x %08x '%c' %s \n", mods, keyCode, key, key, ev);
// */ */
switch (kind) switch (kind)
{ {
case kEventRawKeyDown: case kEventRawKeyDown:
@@ -1345,14 +1345,13 @@ pascal OSStatus carbonKeyboardHandler(
} }
// if the user pressed alt/option, event_key should have the keycap, // if the user pressed alt/option, event_key should have the keycap,
// but event_text should generate the international symbol // but event_text should generate the international symbol
sym = macKeyLookUp[maskedKeyCode];
if ( isalpha(key) ) if ( isalpha(key) )
sym = tolower(key); sym = tolower(key);
else if ( Fl::e_state&FL_CTRL && key<32 ) else if ( Fl::e_state&FL_CTRL && key<32 && sym<0xff00)
sym = key+96; sym = key+96;
else if ( Fl::e_state&FL_ALT ) // find the keycap of this key else if ( Fl::e_state&FL_ALT && sym<0xff00) // find the keycap of this key
sym = keycode_to_sym( maskedKeyCode, 0, macKeyLookUp[ maskedKeyCode ] ); sym = keycode_to_sym( maskedKeyCode, 0, macKeyLookUp[ maskedKeyCode ] );
else
sym = macKeyLookUp[ maskedKeyCode ];
Fl::e_keysym = Fl::e_original_keysym = sym; Fl::e_keysym = Fl::e_original_keysym = sym;
// Handle FL_KP_Enter on regular keyboards and on Powerbooks // Handle FL_KP_Enter on regular keyboards and on Powerbooks
if ( maskedKeyCode==0x4c || maskedKeyCode==0x34) key=0x0d; if ( maskedKeyCode==0x4c || maskedKeyCode==0x34) key=0x0d;