1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-21 13:28:05 +01:00

fixed textfields regarding interpretation of special keys with modifiers

This commit is contained in:
dan
2002-03-14 22:20:25 +00:00
parent 65e65c4e9d
commit 97e20d94de
2 changed files with 85 additions and 93 deletions

View File

@@ -12,6 +12,7 @@ Changes since wmaker 0.80.0:
same case. same case.
- Fixed WMGetViewScreenPosition() to consider the window decorations. - Fixed WMGetViewScreenPosition() to consider the window decorations.
- Added ability to enable/disable individual WMTableViewItems. - Added ability to enable/disable individual WMTableViewItems.
- Fixed textfields regarding interpretation of special keys with modifiers.
Changes since wmaker 0.70.0: Changes since wmaker 0.70.0:

View File

@@ -1018,13 +1018,9 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
if (((XKeyEvent *) event)->state & WM_EMACSKEYMASK) if (((XKeyEvent *) event)->state & WM_EMACSKEYMASK)
control_pressed = 1; control_pressed = 1;
shifted = event->xkey.state & ShiftMask; shifted = (event->xkey.state & ShiftMask ? True : False);
controled = event->xkey.state & ControlMask; controled = (event->xkey.state & ControlMask ? True : False);
if ((event->xkey.state & (ShiftMask|ControlMask)) != 0) { modified = shifted || controled;
modified = True;
} else {
modified = False;
}
count = XLookupString(&event->xkey, buffer, 63, &ksym, NULL); count = XLookupString(&event->xkey, buffer, 63, &ksym, NULL);
buffer[count] = '\0'; buffer[count] = '\0';
@@ -1034,30 +1030,32 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
#ifdef XK_ISO_Left_Tab #ifdef XK_ISO_Left_Tab
case XK_ISO_Left_Tab: case XK_ISO_Left_Tab:
#endif #endif
if (!controled && !modified) { if (!controled) {
if (shifted) { if (shifted) {
if (tPtr->view->prevFocusChain) { if (tPtr->view->prevFocusChain) {
W_SetFocusOfTopLevel(W_TopLevelOfView(tPtr->view), W_SetFocusOfTopLevel(W_TopLevelOfView(tPtr->view),
tPtr->view->prevFocusChain); tPtr->view->prevFocusChain);
tPtr->flags.notIllegalMovement = 1; tPtr->flags.notIllegalMovement = 1;
} }
data = (void*)WMBacktabTextMovement; data = (void*)WMBacktabTextMovement;
} else { } else {
if (tPtr->view->nextFocusChain) { if (tPtr->view->nextFocusChain) {
W_SetFocusOfTopLevel(W_TopLevelOfView(tPtr->view), W_SetFocusOfTopLevel(W_TopLevelOfView(tPtr->view),
tPtr->view->nextFocusChain); tPtr->view->nextFocusChain);
tPtr->flags.notIllegalMovement = 1; tPtr->flags.notIllegalMovement = 1;
} }
data = (void*)WMTabTextMovement; data = (void*)WMTabTextMovement;
} }
textEvent = WMTextDidEndEditingNotification; textEvent = WMTextDidEndEditingNotification;
cancelSelection = 0;
relay = False; relay = False;
} }
break; break;
case XK_Escape: case XK_Escape:
if (!shifted && !controled && !modified) { if (!modified) {
data = (void*)WMEscapeTextMovement; data = (void*)WMEscapeTextMovement;
textEvent = WMTextDidEndEditingNotification; textEvent = WMTextDidEndEditingNotification;
@@ -1066,7 +1064,7 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
break; break;
case XK_Return: case XK_Return:
if (!shifted && !controled && !modified) { if (!modified) {
data = (void*)WMReturnTextMovement; data = (void*)WMReturnTextMovement;
textEvent = WMTextDidEndEditingNotification; textEvent = WMTextDidEndEditingNotification;
@@ -1078,89 +1076,87 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
if (!control_pressed) if (!control_pressed)
goto normal_key; goto normal_key;
else else
modified = False; controled = False;
#ifdef XK_KP_Left #ifdef XK_KP_Left
case XK_KP_Left: case XK_KP_Left:
#endif #endif
case XK_Left: case XK_Left:
if (!modified) { if (tPtr->cursorPosition > 0) {
if (tPtr->cursorPosition > 0) { paintCursor(tPtr);
paintCursor(tPtr); if (controled) {
if (event->xkey.state & ControlMask) { int i = tPtr->cursorPosition - 1;
int i = tPtr->cursorPosition - 1;
while (i > 0 && tPtr->text[i] != ' ') i--; while (i > 0 && tPtr->text[i] != ' ') i--;
while (i > 0 && tPtr->text[i] == ' ') i--; while (i > 0 && tPtr->text[i] == ' ') i--;
tPtr->cursorPosition = (i > 0) ? i + 1 : 0; tPtr->cursorPosition = (i > 0) ? i + 1 : 0;
} else } else
tPtr->cursorPosition--; tPtr->cursorPosition--;
if (tPtr->cursorPosition < tPtr->viewPosition) { if (tPtr->cursorPosition < tPtr->viewPosition) {
tPtr->viewPosition = tPtr->cursorPosition; tPtr->viewPosition = tPtr->cursorPosition;
refresh = 1; refresh = 1;
} else } else
paintCursor(tPtr); paintCursor(tPtr);
} }
if (event->xkey.state & ShiftMask) if (shifted)
cancelSelection = 0; cancelSelection = 0;
relay = False;
relay = False;
}
break; break;
case WM_EMACSKEY_RIGHT: case WM_EMACSKEY_RIGHT:
if (!control_pressed) if (!control_pressed)
goto normal_key; goto normal_key;
else else
modified = False; controled = False;
#ifdef XK_KP_Right #ifdef XK_KP_Right
case XK_KP_Right: case XK_KP_Right:
#endif #endif
case XK_Right: case XK_Right:
if (!modified) { if (tPtr->cursorPosition < tPtr->textLen) {
if (tPtr->cursorPosition < tPtr->textLen) { paintCursor(tPtr);
paintCursor(tPtr); if (controled) {
if (event->xkey.state & ControlMask) { int i = tPtr->cursorPosition;
int i = tPtr->cursorPosition;
while (tPtr->text[i] && tPtr->text[i] != ' ') i++; while (tPtr->text[i] && tPtr->text[i] != ' ') i++;
while (tPtr->text[i] == ' ') i++; while (tPtr->text[i] == ' ') i++;
tPtr->cursorPosition = i; tPtr->cursorPosition = i;
} else { } else {
tPtr->cursorPosition++; tPtr->cursorPosition++;
} }
while (WMWidthOfString(tPtr->font, while (WMWidthOfString(tPtr->font,
&(tPtr->text[tPtr->viewPosition]), &(tPtr->text[tPtr->viewPosition]),
tPtr->cursorPosition-tPtr->viewPosition) tPtr->cursorPosition-tPtr->viewPosition)
> tPtr->usableWidth) { > tPtr->usableWidth) {
tPtr->viewPosition++; tPtr->viewPosition++;
refresh = 1; refresh = 1;
} }
if (!refresh) if (!refresh)
paintCursor(tPtr); paintCursor(tPtr);
} }
if (event->xkey.state & ShiftMask) if (shifted)
cancelSelection = 0; cancelSelection = 0;
relay = False;
relay = False;
}
break; break;
case WM_EMACSKEY_HOME: case WM_EMACSKEY_HOME:
if (!control_pressed) if (!control_pressed)
goto normal_key; goto normal_key;
else { else
modified = False; controled = False;
controled = False;
}
#ifdef XK_KP_Home #ifdef XK_KP_Home
case XK_KP_Home: case XK_KP_Home:
#endif #endif
case XK_Home: case XK_Home:
if (!modified && !controled) { if (!controled) {
if (tPtr->cursorPosition > 0) { if (tPtr->cursorPosition > 0) {
paintCursor(tPtr); paintCursor(tPtr);
tPtr->cursorPosition = 0; tPtr->cursorPosition = 0;
@@ -1170,7 +1166,7 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
} else } else
paintCursor(tPtr); paintCursor(tPtr);
} }
if (event->xkey.state & ShiftMask) if (shifted)
cancelSelection = 0; cancelSelection = 0;
relay = False; relay = False;
@@ -1180,15 +1176,14 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
case WM_EMACSKEY_END: case WM_EMACSKEY_END:
if (!control_pressed) if (!control_pressed)
goto normal_key; goto normal_key;
else { else
modified = False; controled = False;
controled = False;
}
#ifdef XK_KP_End #ifdef XK_KP_End
case XK_KP_End: case XK_KP_End:
#endif #endif
case XK_End: case XK_End:
if (!modified && !controled) { if (!controled) {
if (tPtr->cursorPosition < tPtr->textLen) { if (tPtr->cursorPosition < tPtr->textLen) {
paintCursor(tPtr); paintCursor(tPtr);
tPtr->cursorPosition = tPtr->textLen; tPtr->cursorPosition = tPtr->textLen;
@@ -1203,7 +1198,7 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
if (!refresh) if (!refresh)
paintCursor(tPtr); paintCursor(tPtr);
} }
if (event->xkey.state & ShiftMask) if (shifted)
cancelSelection = 0; cancelSelection = 0;
relay = False; relay = False;
@@ -1212,14 +1207,12 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
case WM_EMACSKEY_BS: case WM_EMACSKEY_BS:
if (!control_pressed) if (!control_pressed)
goto normal_key; goto normal_key;
else { else
modified = False; modified = False;
controled = False;
shifted = False;
}
case XK_BackSpace: case XK_BackSpace:
if (!modified && !shifted && !controled) { if (!modified) {
if (tPtr->selection.count) { if (tPtr->selection.count) {
WMDeleteTextFieldRange(tPtr, tPtr->selection); WMDeleteTextFieldRange(tPtr, tPtr->selection);
data = (void*)WMDeleteTextEvent; data = (void*)WMDeleteTextEvent;
@@ -1240,16 +1233,14 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
case WM_EMACSKEY_DEL: case WM_EMACSKEY_DEL:
if (!control_pressed) if (!control_pressed)
goto normal_key; goto normal_key;
else { else
modified = False; modified = False;
controled = False;
shifted = False;
}
#ifdef XK_KP_Delete #ifdef XK_KP_Delete
case XK_KP_Delete: case XK_KP_Delete:
#endif #endif
case XK_Delete: case XK_Delete:
if (!modified && !controled && !shifted) { if (!modified) {
if (tPtr->selection.count) { if (tPtr->selection.count) {
WMDeleteTextFieldRange(tPtr, tPtr->selection); WMDeleteTextFieldRange(tPtr, tPtr->selection);
data = (void*)WMDeleteTextEvent; data = (void*)WMDeleteTextEvent;