#FEATURE by cg
class: FileApplicationNoteBook::TextEditor
class definition
added:
#characterEncodingInDump:
#isShowingHexDumpHolder
#presentationHolder
#radixInDump:
comment/format in:
#getContents
#initialize
#setCharacterEncodingInDump:
changed:
#presentation
#presentation:
class: FileApplicationNoteBook::TextEditor class
changed: #menu
--- a/FileApplicationNoteBook.st Sun Nov 12 12:47:23 2017 +0100
+++ b/FileApplicationNoteBook.st Sun Nov 12 12:47:39 2017 +0100
@@ -77,15 +77,15 @@
AbstractFileApplicationNoteBookComponent subclass:#TextEditor
instanceVariableNames:'fileContentsModel modifiedChannel editView enableSave
- enableReload presentation changeItemProcess closeApplication
- semaChangeItem wantToPrintAsHexDump printAsHexDump itemChanged
- itemRemoved enableHexToggle md5CheckSum
- md5HashValueComputationProcess viewModifiedChannel
- textEditorModificationTime checkModifiedBlock fileEncodingHolder
- doNotShowFontDialog lockFileEncodingHolder enableSelectInBrowser
- tagsBrowserVisibleHolder tagsBrowser editorToolBarVisibleHolder
- editorOperationsToolBarVisibleHolder
- editorOperationsMenuSpecHolder'
+ enableReload changeItemProcess closeApplication semaChangeItem
+ wantToPrintAsHexDump printAsHexDump itemChanged itemRemoved
+ enableHexToggle md5CheckSum md5HashValueComputationProcess
+ viewModifiedChannel textEditorModificationTime checkModifiedBlock
+ fileEncodingHolder doNotShowFontDialog lockFileEncodingHolder
+ enableSelectInBrowser tagsBrowserVisibleHolder tagsBrowser
+ editorToolBarVisibleHolder editorOperationsToolBarVisibleHolder
+ editorOperationsMenuSpecHolder characterEncodingInDump
+ radixInDump presentationHolder'
classVariableNames:'DefaultTagsBrowserVisible MaxFileSizeLoadedWithoutAsking
DefaultEditorToolBarVisible DefaultEditorOperationsToolBarVisible'
poolDictionaries:''
@@ -5126,6 +5126,61 @@
label: 'Hex'
isButton: true
indication: printAsHexDump
+ submenu:
+ (Menu
+ (
+ (MenuItem
+ label: 'Encoding'
+ submenu:
+ (Menu
+ (
+ (MenuItem
+ label: 'Iso8859-1'
+ itemValue: characterEncodingInDump:
+ argument: #'iso8859-1'
+ )
+ (MenuItem
+ label: 'Ascii7'
+ itemValue: characterEncodingInDump:
+ argument: asii7
+ )
+ (MenuItem
+ label: 'EBCDIC'
+ itemValue: characterEncodingInDump:
+ argument: encdic
+ )
+ )
+ nil
+ nil
+ )
+ )
+ (MenuItem
+ label: '-'
+ )
+ (MenuItem
+ label: 'Hex'
+ itemValue: radixInDump:
+ argument: 16
+ )
+ (MenuItem
+ label: 'Octal'
+ itemValue: radixInDump:
+ argument: 8
+ )
+ (MenuItem
+ label: 'Decimal'
+ itemValue: radixInDump:
+ argument: 10
+ )
+ (MenuItem
+ label: 'Binary'
+ itemValue: radixInDump:
+ argument: 2
+ )
+ )
+ nil
+ nil
+ )
labelImage: (ResourceRetriever ToolbarIconLibrary hexToggleIcon)
)
(MenuItem
@@ -5146,6 +5201,8 @@
nil
nil
)
+
+ "Modified: / 12-11-2017 / 12:23:18 / cg"
!
menuEditorOperationsForHTML
@@ -5417,18 +5474,20 @@
!
presentation
- "return the value of the instance variable 'presentation' (automatically generated)"
-
- presentation isNil ifTrue:[
- presentation := #asText.
- ].
- ^ presentation
-!
-
-presentation:something
- "set the value of the instance variable 'presentation' (automatically generated)"
-
- presentation := something.
+ "return the current presentation (either #hexDump or #asText)"
+
+ ^ self presentationHolder value
+
+ "Modified: / 12-11-2017 / 12:33:43 / cg"
+!
+
+presentation:aSymbol
+ "change the presentation (either #hexDump or #asText)"
+
+ "/ self assert:((aSymbol == #asText) or:[aSymbol == #hexDump]).
+ self presentationHolder value:aSymbol.
+
+ "Modified (comment): / 12-11-2017 / 12:34:44 / cg"
!
semaChangeItem
@@ -5537,6 +5596,19 @@
masterApplication changeModified:aSymbol for:self.
!
+characterEncodingInDump:anEencodingSymbol
+ characterEncodingInDump ~~ anEencodingSymbol ifTrue:[
+ characterEncodingInDump := anEencodingSymbol.
+
+ self presentation == #hexDump ifTrue:[
+ self changeInformation.
+ self setContents.
+ ].
+ ].
+
+ "Created: / 12-11-2017 / 12:22:43 / cg"
+!
+
doClose
self askForChangeWithReload:false forClose:true.
@@ -5739,10 +5811,10 @@
presentation == #hexDump ifTrue:[
"/ self withWaitCursorDo:[
contents := AbstractFileBrowser
- contentsOfFileAsDump:file base:16
+ contentsOfFileAsDump:file base:radixInDump
withLimit:sizeLimit
lastPart:showLastPart
- characterEncoding:#'iso8859-1'.
+ characterEncoding:characterEncodingInDump.
"/ ]
]
]
@@ -5750,7 +5822,7 @@
].
^ contents.
- "Modified: / 12-11-2017 / 12:10:26 / cg"
+ "Modified: / 12-11-2017 / 12:26:40 / cg"
!
getContentsAsTextWithSizeLimit:sizeLimitOrNil
@@ -5834,6 +5906,19 @@
].
!
+radixInDump:radix
+ radixInDump ~~ radix ifTrue:[
+ radixInDump := radix.
+
+ self presentation == #hexDump ifTrue:[
+ self changeInformation.
+ self setContents.
+ ].
+ ].
+
+ "Created: / 12-11-2017 / 12:22:52 / cg"
+!
+
readStream:aStream lineDelimiter:aCharacter encoding:fileEncodingArg
"read from aStream, answer its contents as StringCollection.
The file's lines are delimited by aCharacter.
@@ -6331,6 +6416,15 @@
^ modifiedChannel.
!
+presentationHolder
+ presentationHolder isNil ifTrue:[
+ presentationHolder := ValueHolder with:#asText.
+ ].
+ ^ presentationHolder
+
+ "Created: / 12-11-2017 / 12:32:23 / cg"
+!
+
printAsHexDump
printAsHexDump isNil ifTrue:[
printAsHexDump := false asValue.
@@ -6613,6 +6707,11 @@
initialize
super initialize.
semaChangeItem := Semaphore forMutualExclusion.
+
+ characterEncodingInDump := nil. "/ nil defaults to 'iso8859-1' "
+ radixInDump := 16.
+
+ "Modified (comment): / 12-11-2017 / 12:27:20 / cg"
! !
!FileApplicationNoteBook::TextEditor methodsFor:'printing'!
@@ -6700,6 +6799,14 @@
or:[ self itemChanged value or:[ self itemRemoved value ] ]
!
+isShowingHexDumpHolder
+ ^ BlockValue
+ with:[:v | v == #hexDump]
+ argument:(self presentationHolder)
+
+ "Created: / 12-11-2017 / 12:36:27 / cg"
+!
+
isTextEditor
^ true