--- a/FileApplicationNoteBook.st Thu Aug 08 10:48:08 2013 +0100
+++ b/FileApplicationNoteBook.st Thu Aug 08 11:08:29 2013 +0100
@@ -81,8 +81,11 @@
md5HashValueComputationProcess viewModifiedChannel
textEditorModificationTime checkModifiedBlock fileEncodingHolder
doNotShowFontDialog lockFileEncodingHolder enableSelectInBrowser
- tagsBrowserVisibleHolder tagsBrowser'
- classVariableNames:'DefaultTagsBrowserVisible MaxFileSizeLoadedWithoutAsking'
+ tagsBrowserVisibleHolder tagsBrowser editorToolBarVisibleHolder
+ editorOperationsToolBarVisibleHolder
+ editorOperationsMenuSpecHolder'
+ classVariableNames:'DefaultTagsBrowserVisible MaxFileSizeLoadedWithoutAsking
+ DefaultEditorToolBarVisible DefaultEditorOperationsToolBarVisible'
poolDictionaries:''
privateIn:FileApplicationNoteBook
!
@@ -4526,9 +4529,31 @@
#closeTabButton
''
+#hideEditorOperationsToolBar
+'Hide the additional editor operations menu'
+
+#indentCode
+''
+
+#showEditOperationsToolBar
+'Show the additional editor operations menu'
+
+#undentCode
+''
+
)
! !
+!FileApplicationNoteBook::TextEditor class methodsFor:'image specs'!
+
+hideToolBarIcon
+ <resource: #programImage>
+
+ ^ ToolbarIconLibrary hideToolBarIcon
+
+ "Created: / 02-08-2013 / 16:03:09 / cg"
+! !
+
!FileApplicationNoteBook::TextEditor class methodsFor:'interface specs'!
windowSpec
@@ -4547,64 +4572,103 @@
<resource: #canvas>
^
- #(FullSpec
- name: windowSpec
- window:
- (WindowSpec
- label: 'TextEditor'
- name: 'TextEditor'
- min: (Point 10 10)
- bounds: (Rectangle 0 0 650 300)
- )
- component:
- (SpecCollection
- collection: (
- (VariableHorizontalPanelSpec
- name: 'Panel'
- layout: (LayoutFrame 0 0 0 0 0 1 0 1)
- showHandle: true
- snapMode: max
- component:
- (SpecCollection
- collection: (
- (ViewSpec
- name: 'EditorBox'
- component:
- (SpecCollection
- collection: (
- (MenuPanelSpec
- name: 'MenuTextEditor'
- layout: (LayoutFrame 0 0.0 0 0 0 1.0 32 0)
- level: 0
- menu: menu
- textDefault: true
- )
- (TextEditorSpec
- name: 'TextEditor'
- layout: (LayoutFrame 0 0.0 32 0 0 1.0 0 1.0)
- model: fileContentsModel
- hasHorizontalScrollBar: true
- hasVerticalScrollBar: true
- modifiedChannel: viewModifiedChannel
- acceptCallBack: accept
- allowDoIt: true
- hasKeyboardFocusInitially: false
- viewClassName: 'getEditorClass'
- postBuildCallback: postBuildTextEditor:
- )
+ #(FullSpec
+ name: windowSpec
+ window:
+ (WindowSpec
+ label: 'TextEditor'
+ name: 'TextEditor'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 650 300)
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (VariableHorizontalPanelSpec
+ name: 'Panel'
+ layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+ showHandle: true
+ snapMode: max
+ component:
+ (SpecCollection
+ collection: (
+ (ViewSpec
+ name: 'EditorBox'
+ component:
+ (SpecCollection
+ collection: (
+ (MenuPanelSpec
+ name: 'MenuTextEditor'
+ layout: (LayoutFrame 0 0.0 0 0 0 1.0 30 0)
+ level: 1
+ menu: menu
+ textDefault: true
)
-
- )
- )
+ (ViewSpec
+ name: 'EditorOperationsToolBar'
+ layout: (LayoutFrame 0 0 30 0 0 1 60 0)
+ level: 0
+ visibilityChannel: editorOperationsToolBarVisibleHolder
+ component:
+ (SpecCollection
+ collection: (
+ (ActionButtonSpec
+ label: 'hideToolBarIcon'
+ name: 'HideEditorOperationsToolBarButton'
+ layout: (LayoutFrame 0 0 0 0 13 0 0 1)
+ activeHelpKey: hideEditorOperationsToolBar
+ level: 1
+ hasCharacterOrientedLabel: false
+ translateLabel: true
+ model: hideEditorOperationsToolBar
+ postBuildCallback: hideEditorOperationsToolBarButtonCreated:
+ )
+ (MenuPanelSpec
+ name: 'EditorOperationsToolBarMenu'
+ layout: (LayoutFrame 13 0 0 0 0 1 30 0)
+ level: 1
+ menu: editorOperationsMenuSpecHolder
+ textDefault: true
+ )
+ )
+
+ )
+ )
+ (TextEditorSpec
+ name: 'TextEditor'
+ layout: (LayoutFrame 0 0.0 59 0 0 1.0 0 1.0)
+ model: fileContentsModel
+ hasHorizontalScrollBar: true
+ hasVerticalScrollBar: true
+ modifiedChannel: viewModifiedChannel
+ acceptCallBack: accept
+ allowDoIt: true
+ hasKeyboardFocusInitially: false
+ postBuildCallback: postBuildTextEditor:
+ viewClassName: 'getEditorClass'
+ )
+ (ActionButtonSpec
+ label: '...'
+ name: 'Button1'
+ layout: (LayoutFrame -56 1 5 0 -36 1 27 0)
+ activeHelpKey: showEditOperationsToolBar
+ visibilityChannel: editorOperationsToolBarNotVisibleHolder
+ translateLabel: true
+ model: showEditorOperationsToolBar
+ )
+ )
+
+ )
)
-
- )
- handles: (Any 1.0)
- )
+ )
+
+ )
+ handles: (Any 1.0)
)
-
- )
- )
+ )
+
+ )
+ )
!
xwindowSpec
@@ -4777,6 +4841,218 @@
nil
nil
)
+!
+
+menuEditorOperationsForHTML
+ "This resource specification was automatically generated
+ by the MenuEditor of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+
+ "
+ MenuEditor new openOnClass:FileApplicationNoteBook::TextEditor andSelector:#menuEditorOperationsForHTML
+ (Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::TextEditor menuEditorOperationsForHTML)) startUp
+ "
+
+ <resource: #menu>
+
+ ^
+ #(Menu
+ (
+ (MenuItem
+ activeHelpKey: makeBold
+ label: 'bold'
+ itemValue: editOperationMakeBoldHTML
+ labelImage: (ResourceRetriever ToolbarIconLibrary #'edit_bold_15x15')
+ )
+ (MenuItem
+ activeHelpKey: makeItalic
+ enabled: canEdit
+ label: 'italic'
+ itemValue: editOperationMakeItalicHTML
+ isButton: true
+ labelImage: (ResourceRetriever ToolbarIconLibrary #'edit_italic_15x15')
+ )
+ (MenuItem
+ activeHelpKey: addAnchor
+ enabled: canEdit
+ label: 'anchor'
+ itemValue: editOperationAddAnchorHTML
+ isButton: true
+ labelImage: (ResourceRetriever ToolbarIconLibrary #'edit_anchor15x15')
+ )
+ (MenuItem
+ activeHelpKey: addImage
+ enabled: canEdit
+ label: 'image'
+ itemValue: editOperationAddImageHTML
+ isButton: true
+ labelImage: (ResourceRetriever ToolbarIconLibrary #'edit_image_15x15')
+ )
+ )
+ nil
+ nil
+ )
+
+ "Modified: / 02-08-2013 / 18:21:16 / cg"
+!
+
+menuEditorOperationsForNormalText
+ "This resource specification was automatically generated
+ by the MenuEditor of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+
+ "
+ MenuEditor new openOnClass:FileApplicationNoteBook::TextEditor andSelector:#menuEditorOperationsForNormalText
+ (Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::TextEditor menuEditorOperationsForNormalText)) startUp
+ "
+
+ <resource: #menu>
+
+ ^
+ #(Menu
+ (
+ (MenuItem
+ activeHelpKey: undentCode
+ enabled: canEdit
+ label: 'Undent'
+ itemValue: editOperationUndentCode
+ isButton: true
+ startGroup: right
+ labelImage: (ResourceRetriever ToolbarIconLibrary undent16x16Icon)
+ )
+ (MenuItem
+ activeHelpKey: indentCode
+ enabled: canEdit
+ label: 'Indent'
+ itemValue: editOperationIndentCode
+ isButton: true
+ startGroup: right
+ labelImage: (ResourceRetriever ToolbarIconLibrary indent16x16Icon)
+ )
+ )
+ nil
+ nil
+ )
+
+ "Modified: / 02-08-2013 / 18:21:42 / cg"
+!
+
+menuEditorOperationsForOther
+ "This resource specification was automatically generated
+ by the MenuEditor of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+
+ "
+ MenuEditor new openOnClass:FileApplicationNoteBook::TextEditor andSelector:#menuEditorOperationsForNormalText
+ (Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::TextEditor menuEditorOperationsForNormalText)) startUp
+ "
+
+ <resource: #menu>
+
+ ^
+ #(Menu
+ (
+ (MenuItem
+ activeHelpKey: undentCode
+ enabled: canEdit
+ label: 'Undent'
+ itemValue: editOperationUndentCode
+ isButton: true
+ startGroup: right
+ labelImage: (ResourceRetriever ToolbarIconLibrary undent16x16Icon)
+ )
+ (MenuItem
+ activeHelpKey: indentCode
+ enabled: canEdit
+ label: 'Indent'
+ itemValue: editOperationIndentCode
+ isButton: true
+ startGroup: right
+ labelImage: (ResourceRetriever ToolbarIconLibrary indent16x16Icon)
+ )
+ )
+ nil
+ nil
+ )
+
+ "Created: / 02-08-2013 / 17:09:31 / cg"
+!
+
+menuEditorOperationsForSourceCode
+ "This resource specification was automatically generated
+ by the MenuEditor of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+
+ "
+ MenuEditor new openOnClass:FileApplicationNoteBook::TextEditor andSelector:#menuEditorOperationsForSourceCode
+ (Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::TextEditor menuEditorOperationsForSourceCode)) startUp
+ "
+
+ <resource: #menu>
+
+ ^
+ #(Menu
+ (
+ (MenuItem
+ activeHelpKey: #'help_doIt'
+ label: 'DoIt'
+ itemValue: doIt
+ isButton: true
+ isVisible: doItMenuButtonVisibile
+ labelImage: (ResourceRetriever ToolbarIconLibrary doItIcon)
+ )
+ (MenuItem
+ activeHelpKey: #'help_printIt'
+ label: 'PrintIt'
+ itemValue: printIt
+ isButton: true
+ isVisible: printItMenuButtonVisibile
+ labelImage: (ResourceRetriever ToolbarIconLibrary printItIcon)
+ )
+ (MenuItem
+ activeHelpKey: #'help_inspectIt'
+ label: 'InspectIt'
+ itemValue: inspectIt
+ isButton: true
+ isVisible: inspectItMenuButtonVisibile
+ labelImage: (ResourceRetriever ToolbarIconLibrary inspectItIcon)
+ )
+ (MenuItem
+ activeHelpKey: undentCode
+ enabled: canEdit
+ label: 'Undent'
+ itemValue: editOperationUndentCode
+ isButton: true
+ startGroup: right
+ labelImage: (ResourceRetriever ToolbarIconLibrary undent16x16Icon)
+ )
+ (MenuItem
+ activeHelpKey: indentCode
+ enabled: canEdit
+ label: 'Indent'
+ itemValue: editOperationIndentCode
+ isButton: true
+ startGroup: right
+ labelImage: (ResourceRetriever ToolbarIconLibrary indent16x16Icon)
+ )
+ )
+ nil
+ nil
+ )
+
+ "Modified: / 02-08-2013 / 18:21:58 / cg"
! !
!FileApplicationNoteBook::TextEditor methodsFor:'accessing'!
@@ -4964,6 +5240,82 @@
self saveWithAskForFilename:true.
!
+editOperationAddAnchorHTML
+ |sel new|
+
+ sel := editView selectionAsString.
+ sel isNil ifTrue:[^ self].
+
+ new := '<A HREF="xxx">',editView selectionAsString,'</A>'.
+ editView
+ undoableDo:[
+ editView replaceSelectionBy:new keepCursor:false select:true
+ ]
+ info:'Add Anchor'
+
+ "Created: / 02-08-2013 / 18:16:44 / cg"
+!
+
+editOperationAddImageHTML
+ |new|
+
+ new := '<IMG NOPRINT ALIGN="middle" SRC="xxx.png">'.
+ editView
+ undoableDo:[
+ editView insertStringAtCursor:new
+ ]
+ info:'Add Image'
+
+ "Created: / 02-08-2013 / 18:17:26 / cg"
+!
+
+editOperationIndentCode
+ editView indentBy4
+
+ "Created: / 02-08-2013 / 18:20:18 / cg"
+!
+
+editOperationMakeBoldHTML
+ self editOperationToggleHTML:'Toggle Bold' start:'<b>' end:'</b>'
+
+ "Created: / 02-08-2013 / 18:04:27 / cg"
+!
+
+editOperationMakeItalicHTML
+ self editOperationToggleHTML:'Toggle Italic' start:'<i>' end:'</i>'
+
+ "Created: / 02-08-2013 / 18:14:55 / cg"
+!
+
+editOperationToggleHTML:info start:whatStart end:whatEnd
+ |sel new|
+
+ sel := editView selectionAsString.
+ sel isNil ifTrue:[^ self].
+
+ (sel asLowercase startsWith:whatStart) ifTrue:[
+ new := sel copyFrom: whatStart size+1.
+ (new asLowercase endsWith:whatEnd) ifTrue:[
+ new := new copyButLast:whatEnd size.
+ ]
+ ] ifFalse:[
+ new := whatStart,editView selectionAsString,whatEnd
+ ].
+ editView
+ undoableDo:[
+ editView replaceSelectionBy:new keepCursor:false select:true
+ ]
+ info:info
+
+ "Created: / 02-08-2013 / 18:14:25 / cg"
+!
+
+editOperationUndentCode
+ editView undentBy4
+
+ "Created: / 02-08-2013 / 18:22:47 / cg"
+!
+
getContents
|file fileSize contents presentation alreadyConfirmed answer sizeLimit showLastPart
dontAskAgainHolder|
@@ -5124,6 +5476,12 @@
"Modified: / 27-02-2012 / 22:10:18 / cg"
!
+hideEditorOperationsToolBar
+ self editorOperationsToolBarVisibleHolder value:false
+
+ "Created: / 02-08-2013 / 16:12:00 / cg"
+!
+
openDiffView
|fn diffView text1 l1 text2 l2|
@@ -5376,6 +5734,12 @@
"/ ].
!
+showEditorOperationsToolBar
+ self editorOperationsToolBarVisibleHolder value:true
+
+ "Created: / 02-08-2013 / 16:11:52 / cg"
+!
+
tagSelected:aTag
editView deselect. "/ otherwise, it might jump back to show the selection
editView cursorLine:(aTag lineNumber) col:1.
@@ -5468,6 +5832,12 @@
!FileApplicationNoteBook::TextEditor methodsFor:'aspects'!
+canEdit
+ ^ editView notNil and:[editView isReadOnly not]
+
+ "Created: / 02-08-2013 / 16:45:34 / cg"
+!
+
cursorColLabelHolder
^ BlockValue
with:[:v | v printString]
@@ -5502,6 +5872,31 @@
^ editView
!
+editorOperationsMenuSpecHolder
+ editorOperationsMenuSpecHolder isNil ifTrue:[
+ editorOperationsMenuSpecHolder := self class menuEditorOperationsForNormalText asValue.
+ ].
+ ^ editorOperationsMenuSpecHolder
+
+ "Created: / 02-08-2013 / 16:35:49 / cg"
+!
+
+editorOperationsToolBarNotVisibleHolder
+ ^ BlockValue forLogicalNot:self editorOperationsToolBarVisibleHolder
+
+ "Created: / 02-08-2013 / 16:11:02 / cg"
+!
+
+editorOperationsToolBarVisibleHolder
+ editorOperationsToolBarVisibleHolder isNil ifTrue:[
+ editorOperationsToolBarVisibleHolder := (DefaultEditorOperationsToolBarVisible ? true) asValue.
+ editorOperationsToolBarVisibleHolder onChangeSend:#editorOperationsToolBarVisibilityChanged to:self.
+ ].
+ ^ editorOperationsToolBarVisibleHolder
+
+ "Created: / 02-08-2013 / 15:59:43 / cg"
+!
+
enableHexToggle
enableHexToggle isNil ifTrue:[
enableHexToggle := true asValue.
@@ -5669,6 +6064,30 @@
"/ self fileContentsModel changed:#value.
!
+editorOperationsToolBarVisibilityChanged
+ |editorToolBar editorOperationsToolBar editor topOffset editorOperationsToolBarVisible|
+
+ editorToolBar := self componentAt:#MenuTextEditor.
+
+ editorOperationsToolBar := self componentAt:#EditorOperationsToolBar.
+ editor := self componentAt:#TextEditor.
+
+ topOffset := editorToolBar height.
+ editorOperationsToolBarVisible := self editorOperationsToolBarVisibleHolder value.
+ DefaultEditorToolBarVisible := editorOperationsToolBarVisible.
+ editorOperationsToolBarVisible ifTrue:[
+ topOffset := topOffset + editorOperationsToolBar height.
+ ].
+
+ topOffset := topOffset - 1.
+ editor layout topOffset:topOffset.
+ editor container notNil ifTrue:[
+ editor containerChangedSize.
+ ].
+
+ "Created: / 02-08-2013 / 16:01:01 / cg"
+!
+
itemModified
| modified outDated removed|
@@ -5931,6 +6350,22 @@
].
!
+editorOperationsMenuSpecForMimeType:mimeType
+ mimeType isHtml ifTrue:[
+ ^ self class menuEditorOperationsForHTML.
+ ].
+ mimeType isSmalltalkSource ifTrue:[
+ ^ self class menuEditorOperationsForSourceCode.
+ ].
+ mimeType isTextType ifTrue:[
+ ^ self class menuEditorOperationsForNormalText.
+ ].
+
+ ^ self class menuEditorOperationsForOther.
+
+ "Created: / 02-08-2013 / 18:00:39 / cg"
+!
+
getEditorClass
UserPreferences current useCodeView2InTools ifTrue:[
^ Tools::CodeView2 ? CodeView
@@ -5940,6 +6375,14 @@
"Created: / 06-10-2011 / 11:21:43 / cg"
!
+hideEditorOperationsToolBarButtonCreated:aButton
+ aButton passiveLevel:(MenuPanel defaultLevel).
+ aButton activeLevel:-1.
+ aButton backgroundColor:(MenuPanel defaultBackgroundColor).
+
+ "Created: / 02-08-2013 / 16:01:49 / cg"
+!
+
postBuildTextEditor:aWidget
editView := aWidget scrolledView.
"/ I do not want any non-smalltalk code to be syntaxhighlighted!!
@@ -5964,10 +6407,14 @@
"/ self item isNil ifTrue:[
"/ self item:(DirectoryContentsBrowser itemClass fileName:(Filename homeDirectory construct:'.bashrc')).
"/ ].
+ (self componentAt:#EditorOperationsToolBar) menuHolder:self editorOperationsMenuSpecHolder.
+
self setUpTextView.
self changeInformation.
self tagsBrowserVisibilityChanged.
super postOpenWith:aBuilder
+
+ "Modified: / 02-08-2013 / 17:57:50 / cg"
!
release
@@ -5979,8 +6426,12 @@
!
setUpTextView
- "change the parenthesis-spec of the editor to include $< .. $> if the
- shown document is an html- or xml document"
+ "care for any contents specific settings for the editor
+ For example:
+ - change the parenthesis-spec of the editor to include $< .. $> if the
+ shown document is an html- or xml document,
+ - change the editorOperationsMenu
+ "
|item mimeType suffix parenthesis commentStrings parentesisSpec col|
@@ -6032,14 +6483,28 @@
parentesisSpec notNil ifTrue:[
editView perform:#parenthesisSpecification: with:parentesisSpec ifNotUnderstood:nil
].
-
-
- ].
+ self setupEditorOperationsMenuForMimeType:mimeType.
+ ] ifFalse:[
+ self setupEditorOperationsMenuForMimeType:(MIMETypes mimeTypeFromString:'text/plain').
+ ]
].
editView externalEncoding:self fileEncoding.
]
- "Modified: / 10-04-2007 / 15:24:22 / cg"
+ "Modified: / 02-08-2013 / 16:34:34 / cg"
+!
+
+setupEditorOperationsMenuForMimeType:mimeType
+ |spec|
+
+ spec := self editorOperationsMenuSpecForMimeType:mimeType.
+
+ "/ does not work - why?
+ "/ self editorOperationsMenuSpecHolder value:spec.
+
+ (self componentAt:#EditorOperationsToolBarMenu) menu:spec.
+
+ "Created: / 02-08-2013 / 16:35:21 / cg"
! !
!FileApplicationNoteBook::XMLViewApplication class methodsFor:'defaults'!
@@ -6757,11 +7222,11 @@
!FileApplicationNoteBook class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.278 2013-07-04 23:05:54 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.280 2013-08-06 08:38:55 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.278 2013-07-04 23:05:54 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.280 2013-08-06 08:38:55 cg Exp $'
!
version_HG