Status: Accepted
Owner: [hidden email] New issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 See thread http://lists.gforge.inria.fr/pipermail/pharo-project/2011-August/052016.html 'm typing this message on a mac French keyboard. That means I can obtain the holy brackets [ | ] only through weird keystroke combinations | = shit+option+L [ = shift+option+( where shift+5 is ( Enclosing a text in square brackets would require some finger torture both in Squeak/Pharo shift+option+command+( But this does not work because of #shiftEnclose: rules encountered in #initializeShiftCmdKeyShortcuts (found both ParagraphEditor class and TextEditor class) "Note: Command key overrides shift key, so, for example, cmd-shift-9 produces $9 not $(" '9[,''' do: [ :char | cmdMap at: (char asciiValue + 1) put: #shiftEnclose: ]. "({< and double-quote" "Note: Must use cmd-9 or ctrl-9 to get '()' since cmd-shift-9 is a Mac FKey command." shiftEnclose: is badly designed because it does hardcode the keyboard layout (see below). This is not compatible with modern VMs, at least the mac ones, because they deliver a unicode codePoint for $[ or $|, not a raw keycode. It's easy to remove this anachronism and correct the mapping: "On some keyboards, these characters require a shift" '([<{|"''' do: [:char | cmdMap at: char asciiValue + 1 put: #enclose:]. To avoid pushing a mac-centric change in trunk, I need to know if the Linux/Windows VM would support above modification. Can anyone check for me ? Nicolas Example of hardcoded keyboard layout: TextEditor>>shiftEnclose: aKeyboardEvent "Insert or remove bracket characters around the current selection. Flushes typeahead." | char left right startIndex stopIndex oldSelection which text | char := aKeyboardEvent keyCharacter. char = $9 ifTrue: [ char := $( ]. char = $, ifTrue: [ char := $< ]. char = $[ ifTrue: [ char := ${ ]. char = $' ifTrue: [ char := $" ]. char asciiValue = 27 ifTrue: [ char := ${ ]. "ctrl-[" snip... _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Updates:
Labels: Milestone-1.4 Comment #1 on issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 (No comment was entered for this change.) _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Comment #2 on issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 Indeed the enclose should not be dependent on shift, but rather check if the command key is pressed and the delivered character corresponds to any of '([<{|"''' but your fix doesn't work under ubuntu (with an older image..) ctrl + ' => surrounds the text with a double quote instead of a single quote but the whole code in TextEditor >> #dispatchCommandOn:return: seems like a huge mess to me. _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Comment #3 on issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 so after a quick hack in TextEditor >> #dispatchCommandOn:return: it works: dispatchCommandOn: aKeyboardEvent return: return |asciiValue char| asciiValue := aKeyboardEvent keyValue. ((self class specialShiftCmdKeys includes: asciiValue) and: [ asciiValue < 27]) ifTrue: [ ^ self performCmdActionsWith: aKeyboardEvent shifted: aKeyboardEvent controlKeyPressed return: return]. self cmdKeysInText ifFalse: [ ^ false ]. (aKeyboardEvent commandKeyPressed or: [self class specialShiftCmdKeys includes: asciiValue]) ifTrue: [ ^ self performCmdActionsWith: aKeyboardEvent shifted: aKeyboardEvent shiftPressed return: return]. aKeyboardEvent controlKeyPressed ifTrue: [ ^ self performCmdActionsWith: aKeyboardEvent shifted: false return: return]. ^ false _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Comment #4 on issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 Yes, it seems that some linux vm require some hacks... Name: Morphic-cmm.568 Author: cmm Time: 16 August 2011, 7:41:16.85 pm UUID: 0e5f72e8-32fa-4608-bb91-f08260ecbab5 Ancestors: Morphic-nice.567 - Fixed Auto Enclose preference. - Restored ability to use Control in lieu of Alt+Shift for enclosing with (, {, or double-quote. =============== Diff against Morphic-nice.567 =============== Item was changed: ----- Method: TextEditor class>>initializeShiftCmdKeyShortcuts (in category 'keyboard shortcut tables') ----- initializeShiftCmdKeyShortcuts "Initialize the shift-command-key (or control-key) shortcut table." "NOTE: if you don't know what your keyboard generates, use Sensor kbdTest" "wod 11/3/1998: Fix setting of cmdMap for shifted keys to actually use the capitalized versions of the letters. TPR 2/18/99: add the plain ascii values back in for those VMs that don't return the shifted values." "TextEditor initialize" | cmdMap cmds | "shift-command and control shortcuts" cmdMap := Array new: 256 withAll: #noop:. "use temp in case of a crash" cmdMap at: ( 1 + 1) put: #cursorHome:. "home key" cmdMap at: ( 4 + 1) put: #cursorEnd:. "end key" cmdMap at: ( 8 + 1) put: #forwardDelete:. "ctrl-H or delete key" cmdMap at: (11 + 1) put: #cursorPageUp:. "page up key" cmdMap at: (12 + 1) put: #cursorPageDown:. "page down key" cmdMap at: (13 + 1) put: #crWithIndent:. "ctrl-Return" cmdMap at: (27 + 1) put: #offerMenuFromEsc:. "escape key" cmdMap at: (28 + 1) put: #cursorLeft:. "left arrow key" cmdMap at: (29 + 1) put: #cursorRight:. "right arrow key" cmdMap at: (30 + 1) put: #cursorUp:. "up arrow key" cmdMap at: (31 + 1) put: #cursorDown:. "down arrow key" cmdMap at: (32 + 1) put: #selectWord:. "space bar key" cmdMap at: (45 + 1) put: #changeEmphasis:. "cmd-sh-minus" cmdMap at: (61 + 1) put: #changeEmphasis:. "cmd-sh-plus" cmdMap at: (127 + 1) put: #forwardDelete:. "del key" "On some keyboards, these characters require a shift" + '([<{|"''9' do: [:char | cmdMap at: char asciiValue + 1 put: #enclose:]. - '([<{|"''' do: [:char | cmdMap at: char asciiValue + 1 put: #enclose:]. "NB: sw 12/9/2001 commented out the idiosyncratic line just below, which was grabbing shift-esc in the text editor and hence which argued with the wish to have shift-esc be a universal gesture for escaping the local context and calling up the desktop menu." "cmdMap at: (27 + 1) put: #shiftEnclose:." "ctrl-[" "'""''(' do: [ :char | cmdMap at: (char asciiValue + 1) put: #enclose:]." cmds := #( $c compareToClipboard: $d duplicate: $h cursorTopHome: $j doAgainMany: $k changeStyle: $l outdent: $m selectCurrentTypeIn: $r indent: $s search: $u changeLfToCr: $x makeLowercase: $y makeUppercase: $z makeCapitalized: ). 1 to: cmds size by: 2 do: [ :i | cmdMap at: ((cmds at: i) asciiValue + 1) put: (cmds at: i + 1). "plain keys" cmdMap at: ((cmds at: i) asciiValue - 32 + 1) put: (cmds at: i + 1). "shifted keys" cmdMap at: ((cmds at: i) asciiValue - 96 + 1) put: (cmds at: i + 1). "ctrl keys" ]. shiftCmdActions := cmdMap! Item was changed: ----- Method: TextEditor>>dispatchOnKeyboardEvent: (in category 'typing support') ----- dispatchOnKeyboardEvent: aKeyboardEvent "Carry out the action associated with this character, if any. Type-ahead is passed so some routines can flush or use it." | honorCommandKeys openers closers result | (aKeyboardEvent keyCharacter == Character cr and: [ morph acceptOnCR ]) ifTrue: [ self closeTypeIn. ^ true ]. self clearParens. aKeyboardEvent keyValue = 13 ifTrue: [ aKeyboardEvent controlKeyPressed ifTrue: [ ^ self normalCharacter: aKeyboardEvent ]. aKeyboardEvent shiftPressed ifTrue: [ ^ self lf: aKeyboardEvent ]. aKeyboardEvent commandKeyPressed ifTrue: [ ^ self crlf: aKeyboardEvent ]. ^ self crWithIndent: aKeyboardEvent ]. ((honorCommandKeys := Preferences cmdKeysInText) and: [ aKeyboardEvent keyCharacter = Character enter ]) ifTrue: [ ^ self dispatchOnEnterWith: aKeyboardEvent ]. "Special keys overwrite crtl+key combinations - at least on Windows. To resolve this conflict, assume that keys other than cursor keys aren't used together with Crtl." ((self class specialShiftCmdKeys includes: aKeyboardEvent keyValue) and: [ aKeyboardEvent keyValue < 27 ]) ifTrue: [ ^ aKeyboardEvent controlKeyPressed ifTrue: [ self perform: (self class shiftCmdActions at: aKeyboardEvent keyValue + 1) with: aKeyboardEvent ] ifFalse: [ self perform: (self class cmdActions at: aKeyboardEvent keyValue + 1) with: aKeyboardEvent ] ]. "backspace, and escape keys (ascii 8 and 27) are command keys" ((honorCommandKeys and: [ aKeyboardEvent commandKeyPressed ]) or: [ self class specialShiftCmdKeys includes: aKeyboardEvent keyValue ]) ifTrue: [ ^ aKeyboardEvent shiftPressed ifTrue: [ self perform: (self class shiftCmdActions at: aKeyboardEvent keyValue + 1) with: aKeyboardEvent ] ifFalse: [ self perform: (self class cmdActions at: aKeyboardEvent keyValue + 1) with: aKeyboardEvent ] ]. "the control key can be used to invoke shift-cmd shortcuts" (honorCommandKeys and: [ aKeyboardEvent controlKeyPressed ]) + ifTrue: [^ self perform: (self class shiftCmdActions at: (aKeyboardEvent keyValue + 1)) with: aKeyboardEvent ]. - ifTrue: [ ^ self perform: (self class shiftCmdActions at: aKeyboardEvent keyValue + 1) with: aKeyboardEvent ]. openers := '([{'. closers := ')]}'. result := self normalCharacter: aKeyboardEvent. (closers includes: aKeyboardEvent keyCharacter) ifTrue: [ self blinkPrevParen: aKeyboardEvent ]. (self class autoEnclose and: [ openers includes: aKeyboardEvent keyCharacter ]) ifTrue: [ + markBlock := pointBlock. self addString: (closers at: (openers indexOf: aKeyboardEvent keyCharacter)) asString. + markBlock := pointBlock. self moveCursor: [ :position | position - 1 ] forward: false select: false "no special behavior" ]. ^ result! Item was changed: ----- Method: TextEditor>>enclose: (in category 'editing keys') ----- enclose: aKeyboardEvent "Insert or remove bracket characters around the current selection." | left right startIndex stopIndex oldSelection which t | self closeTypeIn. startIndex := self startIndex. stopIndex := self stopIndex. oldSelection := self selection. + which := '([<{|"''9' indexOf: aKeyboardEvent keyCharacter ifAbsent: [ ^true ]. + "Allow Control key in lieu of Alt+Shift for (, {, and double-quote." + left := ((Preferences cmdKeysInText and: [ aKeyboardEvent controlKeyPressed ]) + ifTrue: [ '({<{|""(' ] + ifFalse: ['([<{|"''(']) at: which. + right := ((Preferences cmdKeysInText and: [ aKeyboardEvent controlKeyPressed ]) + ifTrue: [ ')}>}|"")' ] + ifFalse: [')]>}|"'')']) at: which. - which := '([<{|"''' indexOf: aKeyboardEvent keyCharacter ifAbsent: [ ^true ]. - left := '([<{|"''' at: which. - right := ')]>}|"''' at: which. t := self text. ((startIndex > 1 and: [stopIndex <= t size]) and: [ (t at: startIndex-1) = left and: [(t at: stopIndex) = right]]) ifTrue: [ "already enclosed; strip off brackets" self selectFrom: startIndex-1 to: stopIndex. self replaceSelectionWith: oldSelection] ifFalse: [ "not enclosed; enclose by matching brackets" self replaceSelectionWith: (Text string: (String with: left), oldSelection string, (String with: right) attributes: emphasisHere). self selectFrom: startIndex+1 to: stopIndex]. ^true! _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Comment #5 on issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 ok lets use this as a temporary hack until we get the keymapping into the image and replace everything by more meaningful actions... _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Comment #6 on issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 can you publish something? _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Updates:
Labels: Type-Bug Comment #7 on issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 (No comment was entered for this change.) _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Updates:
Labels: -Milestone-1.4 Comment #8 on issue 4599 by [hidden email]: shiftEnclose: shall not hardcode the keyboard layout http://code.google.com/p/pharo/issues/detail?id=4599 I think we should postpone this to later... has not seen any activity since September 2011. _______________________________________________ Pharo-bugtracker mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker |
Free forum by Nabble | Edit this page |