diff --git a/src/dlangui/core/editable.d b/src/dlangui/core/editable.d index 50ae3518..0b25690c 100644 --- a/src/dlangui/core/editable.d +++ b/src/dlangui/core/editable.d @@ -683,7 +683,7 @@ class EditableContent { if (ch == ' ') { x++; } else if (ch == '\t') { - x = (x + _tabSize) % _tabSize; + x = (x + _tabSize) / _tabSize * _tabSize; } else { if (res.firstNonSpace < 0) { res.firstNonSpace = i; diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d index e680e9ac..83a10cd4 100644 --- a/src/dlangui/platforms/windows/winapp.d +++ b/src/dlangui/platforms/windows/winapp.d @@ -640,8 +640,12 @@ class Win32Window : Window { _keyFlags &= ~flag; } - bool onKey(KeyAction action, uint keyCode, int repeatCount, dchar character = 0) { + bool onKey(KeyAction action, uint keyCode, int repeatCount, dchar character = 0, bool syskey = false) { KeyEvent event; + if (syskey) + _keyFlags |= KeyFlag.Alt; + //else + // _keyFlags &= ~KeyFlag.Alt; if (action == KeyAction.KeyDown || action == KeyAction.KeyUp) { switch(keyCode) { case KeyCode.SHIFT: @@ -654,13 +658,29 @@ class Win32Window : Window { updateKeyFlags(action, KeyFlag.Alt); break; default: + if (GetKeyState(VK_CONTROL) & 0x8000) + _keyFlags |= KeyFlag.Control; + else + _keyFlags &= ~KeyFlag.Control; + if (GetKeyState(VK_SHIFT) & 0x8000) + _keyFlags |= KeyFlag.Shift; + else + _keyFlags &= ~KeyFlag.Shift; break; } + if (keyCode == 0xBF) + keyCode = KeyCode.KEY_DIVIDE; event = new KeyEvent(action, keyCode, _keyFlags); } else if (action == KeyAction.Text && character != 0) { - dchar[] text; - text ~= character; - event = new KeyEvent(action, 0, _keyFlags, cast(dstring)text); + if (_keyFlags & (KeyFlag.Control | KeyFlag.Alt)) { + if (character >= 1 && character <= 26) { + event = new KeyEvent(action, KeyCode.KEY_A + character - 1, _keyFlags); + } + } else { + dchar[] text; + text ~= character; + event = new KeyEvent(action, 0, _keyFlags, cast(dstring)text); + } } bool res = false; if (event !is null) { @@ -1091,7 +1111,7 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_SYSKEYUP: if (window !is null) { int repeatCount = lParam & 0xFFFF; - if (window.onKey(message == WM_KEYDOWN || message == WM_SYSKEYDOWN ? KeyAction.KeyDown : KeyAction.KeyUp, wParam, repeatCount)) + if (window.onKey(message == WM_KEYDOWN || message == WM_SYSKEYDOWN ? KeyAction.KeyDown : KeyAction.KeyUp, wParam, repeatCount, 0, message == WM_SYSKEYUP || message == WM_SYSKEYDOWN)) return 0; // processed } break; diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index 824217cb..7b9b1de5 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -411,9 +411,6 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction /// override to change popup menu items state override bool isActionEnabled(const Action action) { switch (action.id) { - case EditorActions.ToggleBlockComment: - return enabled && !_selectionRange.empty; - case EditorActions.ToggleLineComment: case EditorActions.Tab: case EditorActions.BackTab: case EditorActions.Indent: @@ -908,7 +905,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction case EditorActions.ToggleBlockComment: if (!_content.syntaxHighlighter || !_content.syntaxHighlighter.supportsToggleBlockComment) a.state = ACTION_STATE_INVISIBLE; - else if (_content.syntaxHighlighter.canToggleBlockComment(_selectionRange)) + else if (enabled && _content.syntaxHighlighter.canToggleBlockComment(_selectionRange)) a.state = ACTION_STATE_ENABLED; else a.state = ACTION_STATE_DISABLE; @@ -916,7 +913,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction case EditorActions.ToggleLineComment: if (!_content.syntaxHighlighter || !_content.syntaxHighlighter.supportsToggleLineComment) a.state = ACTION_STATE_INVISIBLE; - else if (_content.syntaxHighlighter.canToggleLineComment(_selectionRange)) + else if (enabled && _content.syntaxHighlighter.canToggleLineComment(_selectionRange)) a.state = ACTION_STATE_ENABLED; else a.state = ACTION_STATE_DISABLE;