The Inbox: Morphic-ct.1621.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Morphic-ct.1621.mcz

commits-2
Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1621.mcz

==================== Summary ====================

Name: Morphic-ct.1621
Author: ct
Time: 22 January 2020, 11:21:19.533972 am
UUID: facc9fb6-e535-c04f-967c-5f2ae09733c6
Ancestors: Morphic-cmm.1618

Proposal: Use Ctrl + Enter to accept in every textmorph, even if acceptOnCR is disabled. Useful, for example, to answer a multiline request.

=============== Diff against Morphic-cmm.1618 ===============

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 typedChar |
  typedChar := aKeyboardEvent keyCharacter.
 
  "Handle one-line input fields."
+ (typedChar == Character lf or: [typedChar == Character cr and: [morph acceptOnCR]])
- (typedChar == Character cr and: [morph acceptOnCR])
  ifTrue: [^ true].
 
  "Clear highlight for last opened parenthesis."
  self clearParens.
 
  "Handle line breaks and auto indent."
  typedChar == Character cr ifTrue: [
  aKeyboardEvent controlKeyPressed
  ifTrue: [^ self normalCharacter: aKeyboardEvent].
  aKeyboardEvent shiftPressed
  ifTrue: [^ self lf: aKeyboardEvent].
  aKeyboardEvent commandKeyPressed
  ifTrue: [^ self crlf: aKeyboardEvent].
  ^ self crWithIndent: aKeyboardEvent].
 
  "Handle indent/outdent with selected text block."
  typedChar == Character tab ifTrue: [
  aKeyboardEvent shiftPressed
  ifTrue: [self outdent: aKeyboardEvent. ^ true]
  ifFalse: [self hasMultipleLinesSelected
  ifTrue: [self indent: aKeyboardEvent. ^ true]]].
 
  honorCommandKeys := Preferences cmdKeysInText.
 
  (honorCommandKeys and: [typedChar == 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].
 
  "Enclose selection with brackets etc."
  ((self class encloseSelection and: [self hasSelection]) and: [self enclose: aKeyboardEvent])
  ifTrue: [^ true].
 
  "Automatically enclose paired characters such as brackets."
  (self class autoEnclose and: [self autoEncloseFor: typedChar])
  ifTrue: [^ true].
 
  "Even if no enclosing feature was used, highlight the matching bracket when closing one."
  (')]}' includes: typedChar)
  ifTrue: [self blinkPrevParen: typedChar].
 
  self normalCharacter: aKeyboardEvent.
  ^ false!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
  | view |
 
  editView deleteBalloon.
  self editor model: editView model.  "For evaluateSelection"
  view := editView.  "Copy into temp for case of a self-mutating doit"
+ (evt keyCharacter = Character lf or: [acceptOnCR and: [evt keyCharacter = Character cr]])
- (acceptOnCR and: [evt keyCharacter = Character cr])
  ifTrue: [^ self editor accept].
 
  view hasUserEdited: false.
  super keyStroke: evt.
  view scrollSelectionIntoView.
 
  view hasUserEdited
  ifTrue: [ view textEdited: self contents].!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Morphic-ct.1621.mcz

Christoph Thiede

The "Character lf" hack works on Windows, but I'm not sure if this behavior is officially defined by the VM. I don't know how one could detect Ctrl + Enter else ...

If you see any problems with solving this issue directly in TextMorph/Editor, we could also handle the event in FillInTheBlankMorph.

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Mittwoch, 22. Januar 2020 11:21 Uhr
An: [hidden email]
Betreff: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1621.mcz

==================== Summary ====================

Name: Morphic-ct.1621
Author: ct
Time: 22 January 2020, 11:21:19.533972 am
UUID: facc9fb6-e535-c04f-967c-5f2ae09733c6
Ancestors: Morphic-cmm.1618

Proposal: Use Ctrl + Enter to accept in every textmorph, even if acceptOnCR is disabled. Useful, for example, to answer a multiline request.

=============== Diff against Morphic-cmm.1618 ===============

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 typedChar |
         typedChar := aKeyboardEvent keyCharacter.
        
         "Handle one-line input fields."
+        (typedChar == Character lf or: [typedChar == Character cr and: [morph acceptOnCR]])
-        (typedChar == Character cr and: [morph acceptOnCR])
                 ifTrue: [^ true].
        
         "Clear highlight for last opened parenthesis."
         self clearParens.
        
         "Handle line breaks and auto indent."
         typedChar == Character cr ifTrue: [
                 aKeyboardEvent controlKeyPressed
                         ifTrue: [^ self normalCharacter: aKeyboardEvent].
                 aKeyboardEvent shiftPressed
                         ifTrue: [^ self lf: aKeyboardEvent].
                 aKeyboardEvent commandKeyPressed
                         ifTrue: [^ self crlf: aKeyboardEvent].
                 ^ self crWithIndent: aKeyboardEvent].
 
         "Handle indent/outdent with selected text block."
         typedChar == Character tab ifTrue: [
                 aKeyboardEvent shiftPressed
                         ifTrue: [self outdent: aKeyboardEvent. ^ true]
                         ifFalse: [self hasMultipleLinesSelected
                                 ifTrue: [self indent: aKeyboardEvent. ^ true]]].
 
         honorCommandKeys := Preferences cmdKeysInText.
 
         (honorCommandKeys and: [typedChar == 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].
 
         "Enclose selection with brackets etc."
         ((self class encloseSelection and: [self hasSelection]) and: [self enclose: aKeyboardEvent])
                 ifTrue: [^ true].
 
         "Automatically enclose paired characters such as brackets."
         (self class autoEnclose and: [self autoEncloseFor: typedChar])
                 ifTrue: [^ true].
                
         "Even if no enclosing feature was used, highlight the matching bracket when closing one."
         (')]}' includes: typedChar)
                 ifTrue: [self blinkPrevParen: typedChar].
                                        
         self normalCharacter: aKeyboardEvent.
         ^ false!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
         | view |
        
         editView deleteBalloon.
         self editor model: editView model.  "For evaluateSelection"
         view := editView.  "Copy into temp for case of a self-mutating doit"
+        (evt keyCharacter = Character lf or: [acceptOnCR and: [evt keyCharacter = Character cr]])
-        (acceptOnCR and: [evt keyCharacter = Character cr])
                 ifTrue: [^ self editor accept].
 
         view hasUserEdited: false.
         super keyStroke: evt.
         view scrollSelectionIntoView.
        
         view hasUserEdited
                 ifTrue: [       view textEdited: self contents].!




Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Morphic-ct.1621.mcz

Chris Muller-3
Does this overload Cmd+s?

On Wed, Jan 22, 2020 at 4:25 AM Thiede, Christoph <[hidden email]> wrote:

The "Character lf" hack works on Windows, but I'm not sure if this behavior is officially defined by the VM. I don't know how one could detect Ctrl + Enter else ...

If you see any problems with solving this issue directly in TextMorph/Editor, we could also handle the event in FillInTheBlankMorph.

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Mittwoch, 22. Januar 2020 11:21 Uhr
An: [hidden email]
Betreff: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1621.mcz

==================== Summary ====================

Name: Morphic-ct.1621
Author: ct
Time: 22 January 2020, 11:21:19.533972 am
UUID: facc9fb6-e535-c04f-967c-5f2ae09733c6
Ancestors: Morphic-cmm.1618

Proposal: Use Ctrl + Enter to accept in every textmorph, even if acceptOnCR is disabled. Useful, for example, to answer a multiline request.

=============== Diff against Morphic-cmm.1618 ===============

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 typedChar |
         typedChar := aKeyboardEvent keyCharacter.
        
         "Handle one-line input fields."
+        (typedChar == Character lf or: [typedChar == Character cr and: [morph acceptOnCR]])
-        (typedChar == Character cr and: [morph acceptOnCR])
                 ifTrue: [^ true].
        
         "Clear highlight for last opened parenthesis."
         self clearParens.
        
         "Handle line breaks and auto indent."
         typedChar == Character cr ifTrue: [
                 aKeyboardEvent controlKeyPressed
                         ifTrue: [^ self normalCharacter: aKeyboardEvent].
                 aKeyboardEvent shiftPressed
                         ifTrue: [^ self lf: aKeyboardEvent].
                 aKeyboardEvent commandKeyPressed
                         ifTrue: [^ self crlf: aKeyboardEvent].
                 ^ self crWithIndent: aKeyboardEvent].
 
         "Handle indent/outdent with selected text block."
         typedChar == Character tab ifTrue: [
                 aKeyboardEvent shiftPressed
                         ifTrue: [self outdent: aKeyboardEvent. ^ true]
                         ifFalse: [self hasMultipleLinesSelected
                                 ifTrue: [self indent: aKeyboardEvent. ^ true]]].
 
         honorCommandKeys := Preferences cmdKeysInText.
 
         (honorCommandKeys and: [typedChar == 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].
 
         "Enclose selection with brackets etc."
         ((self class encloseSelection and: [self hasSelection]) and: [self enclose: aKeyboardEvent])
                 ifTrue: [^ true].
 
         "Automatically enclose paired characters such as brackets."
         (self class autoEnclose and: [self autoEncloseFor: typedChar])
                 ifTrue: [^ true].
                
         "Even if no enclosing feature was used, highlight the matching bracket when closing one."
         (')]}' includes: typedChar)
                 ifTrue: [self blinkPrevParen: typedChar].
                                        
         self normalCharacter: aKeyboardEvent.
         ^ false!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
         | view |
        
         editView deleteBalloon.
         self editor model: editView model.  "For evaluateSelection"
         view := editView.  "Copy into temp for case of a self-mutating doit"
+        (evt keyCharacter = Character lf or: [acceptOnCR and: [evt keyCharacter = Character cr]])
-        (acceptOnCR and: [evt keyCharacter = Character cr])
                 ifTrue: [^ self editor accept].
 
         view hasUserEdited: false.
         super keyStroke: evt.
         view scrollSelectionIntoView.
        
         view hasUserEdited
                 ifTrue: [       view textEdited: self contents].!





Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Morphic-ct.1621.mcz

Christoph Thiede

That is correct. I did not even realize that you can use <cmd>s to answer a FillInTheBlank. I believe that Ctrl + Enter is somehow more intuitive ...

Other opinions? :)


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Chris Muller <[hidden email]>
Gesendet: Mittwoch, 22. Januar 2020 23:43:22
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Does this overload Cmd+s?

On Wed, Jan 22, 2020 at 4:25 AM Thiede, Christoph <[hidden email]> wrote:

The "Character lf" hack works on Windows, but I'm not sure if this behavior is officially defined by the VM. I don't know how one could detect Ctrl + Enter else ...

If you see any problems with solving this issue directly in TextMorph/Editor, we could also handle the event in FillInTheBlankMorph.

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Mittwoch, 22. Januar 2020 11:21 Uhr
An: [hidden email]
Betreff: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1621.mcz

==================== Summary ====================

Name: Morphic-ct.1621
Author: ct
Time: 22 January 2020, 11:21:19.533972 am
UUID: facc9fb6-e535-c04f-967c-5f2ae09733c6
Ancestors: Morphic-cmm.1618

Proposal: Use Ctrl + Enter to accept in every textmorph, even if acceptOnCR is disabled. Useful, for example, to answer a multiline request.

=============== Diff against Morphic-cmm.1618 ===============

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 typedChar |
         typedChar := aKeyboardEvent keyCharacter.
        
         "Handle one-line input fields."
+        (typedChar == Character lf or: [typedChar == Character cr and: [morph acceptOnCR]])
-        (typedChar == Character cr and: [morph acceptOnCR])
                 ifTrue: [^ true].
        
         "Clear highlight for last opened parenthesis."
         self clearParens.
        
         "Handle line breaks and auto indent."
         typedChar == Character cr ifTrue: [
                 aKeyboardEvent controlKeyPressed
                         ifTrue: [^ self normalCharacter: aKeyboardEvent].
                 aKeyboardEvent shiftPressed
                         ifTrue: [^ self lf: aKeyboardEvent].
                 aKeyboardEvent commandKeyPressed
                         ifTrue: [^ self crlf: aKeyboardEvent].
                 ^ self crWithIndent: aKeyboardEvent].
 
         "Handle indent/outdent with selected text block."
         typedChar == Character tab ifTrue: [
                 aKeyboardEvent shiftPressed
                         ifTrue: [self outdent: aKeyboardEvent. ^ true]
                         ifFalse: [self hasMultipleLinesSelected
                                 ifTrue: [self indent: aKeyboardEvent. ^ true]]].
 
         honorCommandKeys := Preferences cmdKeysInText.
 
         (honorCommandKeys and: [typedChar == 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].
 
         "Enclose selection with brackets etc."
         ((self class encloseSelection and: [self hasSelection]) and: [self enclose: aKeyboardEvent])
                 ifTrue: [^ true].
 
         "Automatically enclose paired characters such as brackets."
         (self class autoEnclose and: [self autoEncloseFor: typedChar])
                 ifTrue: [^ true].
                
         "Even if no enclosing feature was used, highlight the matching bracket when closing one."
         (')]}' includes: typedChar)
                 ifTrue: [self blinkPrevParen: typedChar].
                                        
         self normalCharacter: aKeyboardEvent.
         ^ false!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
         | view |
        
         editView deleteBalloon.
         self editor model: editView model.  "For evaluateSelection"
         view := editView.  "Copy into temp for case of a self-mutating doit"
+        (evt keyCharacter = Character lf or: [acceptOnCR and: [evt keyCharacter = Character cr]])
-        (acceptOnCR and: [evt keyCharacter = Character cr])
                 ifTrue: [^ self editor accept].
 
         view hasUserEdited: false.
         super keyStroke: evt.
         view scrollSelectionIntoView.
        
         view hasUserEdited
                 ifTrue: [       view textEdited: self contents].!





Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Morphic-ct.1621.mcz

Jakob Reschke
Ctrl/Cmd+Enter as "submit" or "send" is typical in communication applications, such as instant messengers with long message support, or Microsoft Outlook.

It is harder to reach than Cmd-s but more widely known in the outside world, I assume.

In text processors it might rather mean "page break", but I hope nobody tries to break a page in the FillInTheBlank...

Thiede, Christoph <[hidden email]> schrieb am Do., 23. Jan. 2020, 09:01:

That is correct. I did not even realize that you can use <cmd>s to answer a FillInTheBlank. I believe that Ctrl + Enter is somehow more intuitive ...

Other opinions? :)


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Chris Muller <[hidden email]>
Gesendet: Mittwoch, 22. Januar 2020 23:43:22
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Does this overload Cmd+s?

On Wed, Jan 22, 2020 at 4:25 AM Thiede, Christoph <[hidden email]> wrote:

The "Character lf" hack works on Windows, but I'm not sure if this behavior is officially defined by the VM. I don't know how one could detect Ctrl + Enter else ...

If you see any problems with solving this issue directly in TextMorph/Editor, we could also handle the event in FillInTheBlankMorph.

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Mittwoch, 22. Januar 2020 11:21 Uhr
An: [hidden email]
Betreff: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1621.mcz

==================== Summary ====================

Name: Morphic-ct.1621
Author: ct
Time: 22 January 2020, 11:21:19.533972 am
UUID: facc9fb6-e535-c04f-967c-5f2ae09733c6
Ancestors: Morphic-cmm.1618

Proposal: Use Ctrl + Enter to accept in every textmorph, even if acceptOnCR is disabled. Useful, for example, to answer a multiline request.

=============== Diff against Morphic-cmm.1618 ===============

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 typedChar |
         typedChar := aKeyboardEvent keyCharacter.
        
         "Handle one-line input fields."
+        (typedChar == Character lf or: [typedChar == Character cr and: [morph acceptOnCR]])
-        (typedChar == Character cr and: [morph acceptOnCR])
                 ifTrue: [^ true].
        
         "Clear highlight for last opened parenthesis."
         self clearParens.
        
         "Handle line breaks and auto indent."
         typedChar == Character cr ifTrue: [
                 aKeyboardEvent controlKeyPressed
                         ifTrue: [^ self normalCharacter: aKeyboardEvent].
                 aKeyboardEvent shiftPressed
                         ifTrue: [^ self lf: aKeyboardEvent].
                 aKeyboardEvent commandKeyPressed
                         ifTrue: [^ self crlf: aKeyboardEvent].
                 ^ self crWithIndent: aKeyboardEvent].
 
         "Handle indent/outdent with selected text block."
         typedChar == Character tab ifTrue: [
                 aKeyboardEvent shiftPressed
                         ifTrue: [self outdent: aKeyboardEvent. ^ true]
                         ifFalse: [self hasMultipleLinesSelected
                                 ifTrue: [self indent: aKeyboardEvent. ^ true]]].
 
         honorCommandKeys := Preferences cmdKeysInText.
 
         (honorCommandKeys and: [typedChar == 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].
 
         "Enclose selection with brackets etc."
         ((self class encloseSelection and: [self hasSelection]) and: [self enclose: aKeyboardEvent])
                 ifTrue: [^ true].
 
         "Automatically enclose paired characters such as brackets."
         (self class autoEnclose and: [self autoEncloseFor: typedChar])
                 ifTrue: [^ true].
                
         "Even if no enclosing feature was used, highlight the matching bracket when closing one."
         (')]}' includes: typedChar)
                 ifTrue: [self blinkPrevParen: typedChar].
                                        
         self normalCharacter: aKeyboardEvent.
         ^ false!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
         | view |
        
         editView deleteBalloon.
         self editor model: editView model.  "For evaluateSelection"
         view := editView.  "Copy into temp for case of a self-mutating doit"
+        (evt keyCharacter = Character lf or: [acceptOnCR and: [evt keyCharacter = Character cr]])
-        (acceptOnCR and: [evt keyCharacter = Character cr])
                 ifTrue: [^ self editor accept].
 
         view hasUserEdited: false.
         super keyStroke: evt.
         view scrollSelectionIntoView.
        
         view hasUserEdited
                 ifTrue: [       view textEdited: self contents].!






Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Morphic-ct.1621.mcz

Christoph Thiede

In text processors it might rather mean "page break", but I hope nobody tries to break a page in the FillInTheBlank...


Please note that this suggestion affects all kinds of TextEditors. If someone should try to implement Word in Squeak, this might be a hypothetical problem. :)

Also, I wonder whether this shortcut could lead to problems in widgets that do not support accepting at all?

Best,
Christoph

Von: Squeak-dev <[hidden email]> im Auftrag von Jakob Reschke <[hidden email]>
Gesendet: Freitag, 24. Januar 2020 10:12:08
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Ctrl/Cmd+Enter as "submit" or "send" is typical in communication applications, such as instant messengers with long message support, or Microsoft Outlook.

It is harder to reach than Cmd-s but more widely known in the outside world, I assume.

In text processors it might rather mean "page break", but I hope nobody tries to break a page in the FillInTheBlank...

Thiede, Christoph <[hidden email]> schrieb am Do., 23. Jan. 2020, 09:01:

That is correct. I did not even realize that you can use <cmd>s to answer a FillInTheBlank. I believe that Ctrl + Enter is somehow more intuitive ...

Other opinions? :)


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Chris Muller <[hidden email]>
Gesendet: Mittwoch, 22. Januar 2020 23:43:22
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Does this overload Cmd+s?

On Wed, Jan 22, 2020 at 4:25 AM Thiede, Christoph <[hidden email]> wrote:

The "Character lf" hack works on Windows, but I'm not sure if this behavior is officially defined by the VM. I don't know how one could detect Ctrl + Enter else ...

If you see any problems with solving this issue directly in TextMorph/Editor, we could also handle the event in FillInTheBlankMorph.

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Mittwoch, 22. Januar 2020 11:21 Uhr
An: [hidden email]
Betreff: [squeak-dev] The Inbox: Morphic-ct.1621.mcz
 
Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1621.mcz

==================== Summary ====================

Name: Morphic-ct.1621
Author: ct
Time: 22 January 2020, 11:21:19.533972 am
UUID: facc9fb6-e535-c04f-967c-5f2ae09733c6
Ancestors: Morphic-cmm.1618

Proposal: Use Ctrl + Enter to accept in every textmorph, even if acceptOnCR is disabled. Useful, for example, to answer a multiline request.

=============== Diff against Morphic-cmm.1618 ===============

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 typedChar |
         typedChar := aKeyboardEvent keyCharacter.
        
         "Handle one-line input fields."
+        (typedChar == Character lf or: [typedChar == Character cr and: [morph acceptOnCR]])
-        (typedChar == Character cr and: [morph acceptOnCR])
                 ifTrue: [^ true].
        
         "Clear highlight for last opened parenthesis."
         self clearParens.
        
         "Handle line breaks and auto indent."
         typedChar == Character cr ifTrue: [
                 aKeyboardEvent controlKeyPressed
                         ifTrue: [^ self normalCharacter: aKeyboardEvent].
                 aKeyboardEvent shiftPressed
                         ifTrue: [^ self lf: aKeyboardEvent].
                 aKeyboardEvent commandKeyPressed
                         ifTrue: [^ self crlf: aKeyboardEvent].
                 ^ self crWithIndent: aKeyboardEvent].
 
         "Handle indent/outdent with selected text block."
         typedChar == Character tab ifTrue: [
                 aKeyboardEvent shiftPressed
                         ifTrue: [self outdent: aKeyboardEvent. ^ true]
                         ifFalse: [self hasMultipleLinesSelected
                                 ifTrue: [self indent: aKeyboardEvent. ^ true]]].
 
         honorCommandKeys := Preferences cmdKeysInText.
 
         (honorCommandKeys and: [typedChar == 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].
 
         "Enclose selection with brackets etc."
         ((self class encloseSelection and: [self hasSelection]) and: [self enclose: aKeyboardEvent])
                 ifTrue: [^ true].
 
         "Automatically enclose paired characters such as brackets."
         (self class autoEnclose and: [self autoEncloseFor: typedChar])
                 ifTrue: [^ true].
                
         "Even if no enclosing feature was used, highlight the matching bracket when closing one."
         (')]}' includes: typedChar)
                 ifTrue: [self blinkPrevParen: typedChar].
                                        
         self normalCharacter: aKeyboardEvent.
         ^ false!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
         | view |
        
         editView deleteBalloon.
         self editor model: editView model.  "For evaluateSelection"
         view := editView.  "Copy into temp for case of a self-mutating doit"
+        (evt keyCharacter = Character lf or: [acceptOnCR and: [evt keyCharacter = Character cr]])
-        (acceptOnCR and: [evt keyCharacter = Character cr])
                 ifTrue: [^ self editor accept].
 
         view hasUserEdited: false.
         super keyStroke: evt.
         view scrollSelectionIntoView.
        
         view hasUserEdited
                 ifTrue: [       view textEdited: self contents].!






Carpe Squeak!