Hi,
I'm missing some comfort in the workspace and class browser editor. For example I'd like to have some shortcuts for: - deleting a complete line including the line feed at the end of the line - duplicating the current line Also I'd like to have this additional functionality: - have the cursor jumping to the first non-whitespace character of the line when pressing the home key - automatic indenting (not necessarily in terms of Smalltalk syntax but simply when the previous line was indented the editor should indent the next new line automatically with the same indent) Does such an extension already exist? If not: Any hints how to modify the editor to achieve the desired behaviour? Where should I start? Thanks for any hints. Regards, Florian. |
"Florian von Walter" <[hidden email]> wrote in message
news:opscxhihr888pkfg@pc33434... > Hi, > > I'm missing some comfort in the workspace and class browser editor. > For example I'd like to have some shortcuts for: > - deleting a complete line including the line feed at the end of the line The Shift+Ctrl+L shortcut already does that, drop the Shift to cut the line to the paste buffer. > - duplicating the current line > > Also I'd like to have this additional functionality: > - have the cursor jumping to the first non-whitespace character of the > line when pressing the home key I previously posted something similar before. You can find it in Google groups if you search there for: home group:comp.lang.smalltalk.dolphin Its the first hit - I won't paste the link here because its long and I think its probably easier to perform the search anew rather than attempting to reconstruct a chopped up link. This package changes the behaviour of the home key in a slightly different way, but should give you a good start. > - automatic indenting (not necessarily in terms of Smalltalk syntax > but simply when the previous line was indented the editor should > indent the next new line automatically with the same indent) > > Does such an extension already exist? > If not: Any hints how to modify the editor to achieve the desired > behaviour? Where should I start? I suspect some people may have such add-ons, but they may not have wanted to go to the effort of publishing them because really that means creating an IDE extension (the standard image contains an example of such as the 'Dolphin IDE Extension Example'). This is particularly important when you want to extend the menus, because you otherwise need to edit the view resources. For your own private purposes I suggest you start off with just extending the tools by adding some loose methods and some additional shortcut keys. This is easy, and you aren't likely to create a serious clash if you are happy with the existing menus. Anyway, I've pasted below a further method to add the line duplication functionality. It inserts a copy of the current line and then moves the cursor down to the same column in the newly duplicated line. If you wanted to leave the caret where it was, just remove the '+ newText size' from the last expression. I'd be interested to know which behaviour people prefer or expect from using other editors. In order to wire it up to a shortcut key, I chose Ctrl+J, you can evaluate an expression like this: SmalltalkWorkspace acceleratorKeyBindings: (SmalltalkWorkspace acceleratorKeyBindings at: 'Ctrl+J' put: #duplicateLine; yourself) BTW: This will only work in newly opened browsers. Existing browsers won't see the new key binding. You'll have to save the image to have this setting persist. The 'indecisive home' package I previously posted shows how to perform this operation in a package script so that you can build a self-contained extension package. Lastly the next version of Dolphin has a significantly improved editor. This is based on the very powerful Scintilla control, and D6 exposes all of the features in an appropriate object-oriented manner. Regards Blair ---------------------------- !MultilineTextEdit methodsFor! duplicateLine | line caret text range newText | caret := self caretPosition. line := self lineFromPosition: caret. range := self lineRange: line. text := self plainTextRange: range. newText := String lineDelimiter , text. self caretPosition: range stop + 1; replaceSelection: newText; caretPosition: caret + newText size! ! |
"Blair McGlashan" <[hidden email]> wrote in message
news:[hidden email] On the subject of extending editors, there is one trick I recall seeing in a Smalltalk editor years ago (probably an old version of Digitalk Smalltalk/V, but I can't be sure) which I would find handy in Dolphin. If you double-clicked on any left bracket (round, square or curly), it would highlight everything up to the matching right bracket; double-clicking a right bracket highlighted backwards to the matching left bracket. I often get in a tangle with nested brackets, and this was a useful tool to sort things out. Any chance of such a facility in Dolphin? Peter Kenny |
Peter Kenny wrote:
> On the subject of extending editors, there is one trick I recall seeing in a > Smalltalk editor years ago (probably an old version of Digitalk Smalltalk/V, In my view one of the most useful editing tricks in ST/V was pressing Alt-Z to maximize/minimize the window-pane currently under focus, making it fast to see more of the actual method-code when editing it. I wish Dolphin had this feature too. Bracket matching should be a standard feature in any code-editor. -Panu Viljamaa |
In reply to this post by Blair McGlashan-3
On Fri, 20 Aug 2004 09:39:58 +0100, Blair McGlashan <[hidden email]> wrote:
> The Shift+Ctrl+L shortcut already does that, drop the Shift to cut the > line to the paste buffer. :-O Seems I should have look under Help/Key Bindings first. Thanks for the hint. > I previously posted something similar before. You can find it in Google > groups if you search there for: > home group:comp.lang.smalltalk.dolphin Found it. Thanks. > I suspect some people may have such add-ons, but they may not have > wanted to > go to the effort of publishing them because really that means creating an > IDE extension (the standard image contains an example of such as the > 'Dolphin IDE Extension Example'). This is particularly important when you > want to extend the menus, because you otherwise need to edit the view > resources. > > For your own private purposes I suggest you start off with just extending > the tools by adding some loose methods and some additional shortcut keys. > This is easy, and you aren't likely to create a serious clash if you are > happy with the existing menus. > > Anyway, I've pasted below a further method to add the line duplication > functionality. It inserts a copy of the current line and then moves the > cursor down to the same column in the newly duplicated line. If you > wanted > to leave the caret where it was, just remove the '+ newText size' from > the > last expression. I'd be interested to know which behaviour people prefer > or > expect from using other editors. Thanks for the code. This is exactly what I looked for. I have retrieved the package you already posted and added your code to it and improved the package comment somewhat. It is attached below for anyone who is interested in the same functionality. I will try to add the indenting by myself later. > Lastly the next version of Dolphin has a significantly improved editor. > This is based on the very powerful Scintilla control, and D6 exposes all > of the features in an appropriate object-oriented manner. I'm using SciTE (a small editor that also uses the Scintilla control) as a replacement for Notepad daily. SciTE has Ctrl+L to delete a line completely and Ctrl+D to duplicate a line. I'm so used to these nice productivity features that I can't live without them. It's nice to hear that Dolphin will use this in the next version (not asking when the next version will be available after reading the previous related threads on this topic ;-) ). Blair, thanks for your great service. I really appreciate it. Regards, Florian. ----------------------------- | package | package := Package name: 'Dolphin Custom Key Binding Example'. package paxVersion: 0; basicComment: 'This package illustrates extending the IDE by adding some custom key bindings. First, the behaviour of the Home key is changed to jump to the first non-whitespace character in the line instead of jumping at the start of the line. A second press of the Home key will then jump to the start of the line. Further hits on the Home key will toggle between the start of the line and the start of the text in the line. Second, a "Duplicate line" feature bound to the shortcut "Ctrl+J" is added. It will duplicate the current line below the current line and set the cursor in the duplicated line at the same position. The bindings will only work in newly opened class browsers and workspaces. You must close and re-open already open class browsers and workspace after the package is installed. The package will add and remove the key bindings after installation and uninstallation of the package. See the "Scripts/postinstall" and "Scripts/postuninstall" tab for more information. There is also an alternative implementation for the Home key behaviour in method #indecisiveHome1 which will jump to the start of the line on the first press of the Home key and to the start of the text on the second press of the Home key. If you want to use this behaviour you must change the preinstall and postinstall script to use #indecisiveHome1 instead of #indecisiveHome, save the package, uninstall the package and reinstall the package.'. package basicScriptAt: #postinstall put: '| bindings | bindings := SmalltalkWorkspace acceleratorKeyBindings. bindings at: ''Home'' put: #indecisiveHome; at: ''Ctrl+J'' put: #duplicateLine. SmalltalkWorkspace acceleratorKeyBindings: bindings!!'. package basicScriptAt: #postuninstall put: '| bindings | bindings := SmalltalkWorkspace acceleratorKeyBindings. bindings removeKey: ''Home'' ifAbsent: []; removeKey: ''Ctrl+J'' ifAbsent: []. SmalltalkWorkspace acceleratorKeyBindings: bindings!!'. package methodNames add: #MultilineTextEdit -> #duplicateLine; add: #SmalltalkWorkspace -> #indecisiveHome; add: #SmalltalkWorkspace -> #indecisiveHome1; yourself. package binaryGlobalNames: (Set new yourself). package globalAliases: (Set new yourself). package allResourceNames: (Set new yourself). package setPrerequisites: (IdentitySet new add: '..\..\..\prg\Dolphin Smalltalk XP 5.1\Images\Object Arts\Dolphin\IDE\Base\Development System'; add: '..\..\..\prg\Dolphin Smalltalk XP 5.1\Images\Object Arts\Dolphin\Base\Dolphin'; add: '..\..\..\prg\Dolphin Smalltalk XP 5.1\Images\Object Arts\Dolphin\MVP\Base\Dolphin MVP Base'; yourself). package! "Class Definitions"! "Global Aliases"! "Loose Methods"! !MultilineTextEdit methodsFor! duplicateLine | line caret text range newText | caret := self caretPosition. line := self lineFromPosition: caret. range := self lineRange: line. text := self plainTextRange: range. newText := String lineDelimiter , text. self caretPosition: range stop + 1; replaceSelection: newText; caretPosition: caret + newText size! ! !MultilineTextEdit categoriesFor: #duplicateLine!public! ! !SmalltalkWorkspace methodsFor! indecisiveHome | caret line startOfLine firstNonBlank stream | caret := self view caretPosition. line := self view lineFromPosition: caret. startOfLine := self view positionAtLine: line. firstNonBlank := startOfLine. "#textAtLine is a private method. Note the method comment is wrong, the index is one-based" stream := (self view textAtLine: line) readStream. firstNonBlank := stream skipSeparators ifTrue: [startOfLine + stream position] ifFalse: [startOfLine]. self view caretPosition: (caret = firstNonBlank ifTrue: [startOfLine] ifFalse: [firstNonBlank])! indecisiveHome1 | caret line startOfLine | caret := self view caretPosition. caret = 1 ifTrue: [Sound beep. ^self]. line := self view lineFromPosition: caret. startOfLine := self view positionAtLine: line. self view caretPosition: (caret = startOfLine ifTrue: [1] ifFalse: [startOfLine])! ! !SmalltalkWorkspace categoriesFor: #indecisiveHome!commands!public! ! !SmalltalkWorkspace categoriesFor: #indecisiveHome1!commands!public! ! "End of package definition"! "Source Globals"! "Classes"! "Binary Globals"! "Resources"! |
Free forum by Nabble | Edit this page |