TextView.st
author claus
Mon, 28 Nov 1994 22:05:43 +0100
changeset 70 14443a9ea4ec
parent 63 f4eaf04d1eaf
child 77 565b052f5277
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
ListView subclass:#TextView
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    14
       instanceVariableNames:'selectionStartLine selectionStartCol
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    15
			      selectionEndLine selectionEndCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    16
			      clickStartLine clickStartCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    17
			      clickLine clickCol clickCount
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    18
			      wordStartCol wordStartLine wordEndCol wordEndLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    19
			      selectionFgColor selectionBgColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    20
			      fileBox searchBox lineNumberBox
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    21
			      selectStyle 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    22
			      directoryForFileDialog
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    23
			      contentsWasSaved'
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    24
       classVariableNames:'MyFontPanel
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    25
			   DefaultFont
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    26
			   DefaultViewBackground
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    27
			   DefaultSelectionForegroundColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    28
			   DefaultSelectionBackgroundColor'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    29
       poolDictionaries:''
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    30
       category:'Views-Text'
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    31
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    32
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    33
TextView comment:'
5
claus
parents: 3
diff changeset
    34
COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    35
	     All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    36
70
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
    37
$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.13 1994-11-28 21:05:24 claus Exp $
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    38
'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    39
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    40
!TextView class methodsFor:'documentation'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    41
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    42
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    43
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    44
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    45
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    46
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    47
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    48
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    49
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    50
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    51
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    52
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    53
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    54
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    55
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    56
version
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    57
"
70
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
    58
$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.13 1994-11-28 21:05:24 claus Exp $
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    59
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    60
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    61
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
    62
documentation
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    63
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    64
    a view for text - this class adds selections to a simple list.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    65
    The text is not editable and there is no cursor.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    66
    Use TextViews for readonly text.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    67
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    68
    Instance variables:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    69
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    70
    selectionStartLine      <Number>                the line of the selection start (or nil)
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    71
    selectionStartCol       <Number>                the col of the selection start
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    72
    selectionEndLine        <Number>                the line of the selection end
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    73
    selectionEndCol         <Number>                the col of the selection end
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    74
    clickStartLine          <Number>                temporary
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    75
    clickStartCol           <Number>                temporary
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    76
    clickLine               <Number>                temporary
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    77
    clickCol                <Number>                temporary
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    78
    clickCount              <Number>                temporary
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    79
    selectionFgColor        <Color>                 color used to draw selections
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    80
    selectionBgColor        <Color>                 color used to draw selections
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    81
    fileBox                 <FileSelectionBox>      box for save
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    82
    searchBox               <EnterBox2>             box to enter searchpattern
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    83
    lineNumberBox           <EnterBox>              box to enter linenumber
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    84
    selectStyle             <Symbol>                how words are selected
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    85
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    86
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    87
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    88
!TextView class methodsFor:'startup'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    89
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    90
setupEmpty
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    91
    "create a textview in a topview, with horizontal and
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    92
     vertical scrollbars - a helper for #startWith: and #startOn:"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    93
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    94
    |top frame label|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    95
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    96
    label := 'unnamed'.
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    97
    top := StandardSystemView 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    98
		label:label
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    99
		 icon:(Form fromFile:'Editor.xbm' resolution:100).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   100
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   101
    frame := HVScrollableView 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   102
		for:self 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   103
		miniScrollerH:true miniScrollerV:false
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   104
		in:top.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   105
    frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   106
    ^ frame scrolledView
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   107
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   108
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   109
open
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   110
    "start an empty TextView"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   111
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   112
    ^ self openWith:nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   113
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   114
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   115
openWith:aString
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   116
    "start a textView with aString as initial contents"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   117
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   118
    |top textView|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   119
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   120
    textView := self setupEmpty.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   121
    top := textView topView.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   122
    aString notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   123
	textView contents:aString
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   124
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   125
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   126
    top open.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   127
    ^ textView
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   128
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   129
    "
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   130
     TextView openWith:'some text'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   131
     EditTextView openWith:'some text'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   132
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   133
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   134
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   135
openOn:aFileName
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   136
    "start a textView on a file"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   137
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   138
    |top textView|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   139
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   140
    textView := self setupEmpty.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   141
    top := textView topView.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   142
    aFileName notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   143
	top label:(OperatingSystem baseNameOf:aFileName).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   144
	textView contents:(aFileName asFilename readStream contents)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   145
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   146
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   147
    top open.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   148
    ^ textView
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   149
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   150
    "
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   151
     TextView openOn:'../doc/info.doc'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   152
     EditTextView openOn:'../doc/info.doc'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   153
    "
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   154
! !
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   155
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   156
!TextView class methodsFor:'defaults'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   157
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   158
updateStyleCache
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   159
    DefaultViewBackground := StyleSheet colorAt:'textViewBackground' default:White.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   160
    DefaultSelectionForegroundColor := StyleSheet colorAt:'textSelectionForegroundColor'.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   161
    DefaultSelectionBackgroundColor := StyleSheet colorAt:'textSelectionBackgroundColor'.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   162
    DefaultFont := StyleSheet fontAt:'textFont'.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   163
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   164
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   165
!TextView methodsFor:'initialize & release'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   166
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   167
initialize
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   168
    super initialize.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   169
    contentsWasSaved := false.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   170
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   171
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   172
initStyle
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   173
    super initStyle.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   174
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   175
    DefaultFont notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   176
	font := DefaultFont on:device
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   177
    ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   178
    viewBackground := DefaultViewBackground.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   179
    selectionFgColor := DefaultSelectionForegroundColor.
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   180
    selectionFgColor isNil ifTrue:[selectionFgColor := bgColor].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   181
    selectionBgColor := DefaultSelectionBackgroundColor.
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   182
    selectionBgColor isNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   183
	device hasColors ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   184
	    DefaultSelectionForegroundColor isNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   185
		selectionFgColor := fgColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   186
	    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   187
	    selectionBgColor := Color green
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   188
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   189
	    device hasGreyscales ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   190
		DefaultSelectionForegroundColor isNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   191
		    selectionFgColor := fgColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   192
		].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   193
		selectionBgColor := Color grey
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   194
	    ] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   195
		selectionBgColor := fgColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   196
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   197
	]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   198
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   199
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   200
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   201
initEvents
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   202
    super initEvents.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   203
    self enableButtonEvents.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   204
    self enableButtonMotionEvents
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   205
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   206
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   207
initializeMiddleButtonMenu
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   208
    |labels|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   209
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   210
    labels := resources array:#(
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   211
				       'copy'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   212
				       '-'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   213
				       'font ...'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   214
				       '-'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   215
				       'search ...'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   216
				       'goto ...'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   217
				       '-'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   218
				       'save as ...'
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   219
				       'print').
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   220
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   221
    self middleButtonMenu:(PopUpMenu
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   222
				labels:labels
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   223
			     selectors:#(copySelection
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   224
					 nil
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   225
					 changeFont
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   226
					 nil
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   227
					 search
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   228
					 gotoLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   229
					 nil
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   230
					 save
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   231
					 print)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   232
				receiver:self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   233
				     for:self).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   234
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   235
    self enableOrDisableSelectionMenuEntries
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   236
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   237
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   238
destroy
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   239
    fileBox notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   240
	fileBox destroy.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   241
	fileBox := nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   242
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   243
    searchBox notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   244
	searchBox destroy.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   245
	searchBox := nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   246
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   247
    lineNumberBox notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   248
	lineNumberBox destroy.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   249
	lineNumberBox := nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   250
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   251
    super destroy
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   252
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   253
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   254
!TextView methodsFor:'accessing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   255
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   256
selectionForegroundColor:color1 backgroundColor:color2
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   257
    "set both selection-foreground and cursor background colors"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   258
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   259
    selectionFgColor := color1 on:device.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   260
    selectionBgColor := color2 on:device.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   261
    shown ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   262
	self redraw
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   263
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   264
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   265
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   266
setList:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   267
    "set the displayed contents (a collection of strings)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   268
     without redraw.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   269
     Redefined since changing contents implies deselect"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   270
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   271
    self unselect.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   272
    super setList:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   273
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   274
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   275
list:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   276
    "set the displayed contents (a collection of strings)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   277
     with redraw.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   278
     Redefined since changing contents implies deselect"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   279
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   280
    self unselect.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   281
    super list:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   282
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   283
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   284
characterAtLine:lineNr col:colNr
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   285
    "return the character at physical line/col -
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   286
     return space if nothing is there"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   287
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   288
    |line|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   289
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   290
    list notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   291
	line := self listAt:lineNr.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   292
	line notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   293
	    (line size >= colNr) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   294
		^ line at:colNr
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   295
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   296
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   297
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   298
    ^ Character space
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   299
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   300
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   301
characterPositionOfSelection
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   302
    "return the character index of the first character in the selection"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   303
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   304
    selectionStartLine isNil ifTrue:[^ 1].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   305
    ^ self characterPositionOfLine:selectionStartLine
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   306
			       col:selectionStartCol
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   307
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   308
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   309
directoryForFileDialog:aDirectory
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   310
    "define the directory to use for save-box"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   311
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   312
    directoryForFileDialog := aDirectory
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   313
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   314
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   315
contentsWasSaved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   316
    "return true, if the contents was saved (by a save action),
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   317
     false if not (or was modified again after the last save)."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   318
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   319
    ^ contentsWasSaved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   320
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   321
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   322
fromFile:aFileName
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   323
    "take contents from a named file"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   324
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   325
    self directoryForFileDialog:(OperatingSystem directoryNameOf:aFileName).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   326
    self contents:(FileStream oldFileNamed:aFileName) contents
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   327
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   328
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   329
!TextView methodsFor:'private'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   330
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   331
fileOutContentsOn:aStream
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   332
    "save contents on a stream, replacing leading spaces by tab-characters."
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   333
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   334
    self fileOutContentsOn:aStream compressTabs:true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   335
!
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   336
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   337
fileOutContentsOn:aStream compressTabs:compressTabs
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   338
    "save contents on a stream. If compressTabs is true,
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   339
     leading spaces will be replaced by tab-characters in the output."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   340
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   341
    |startNr nLines string|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   342
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   343
    "on some systems, writing linewise is very slow (via NFS)
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   344
     therefore we convert to a string and write it in big chunks.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   345
     To avoid creating huge strings, we do it in blocks of 1000 lines,
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   346
     limiting temporary string creation to about 50-80k.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   347
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   348
    startNr := 1.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   349
    nLines := list size.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   350
    [startNr <= nLines] whileTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   351
	string := list asStringFrom:startNr 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   352
				 to:((startNr + 1000) min:nLines)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   353
		       compressTabs:compressTabs.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   354
	aStream nextPutAll:string.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   355
	startNr := startNr + 1000 + 1.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   356
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   357
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   358
"the old (obsolete) code:
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   359
    list do:[:aLine |
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   360
      aLine notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   361
	  aStream nextPutAll:aLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   362
      ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   363
      aStream cr
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   364
  ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   365
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   366
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   367
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   368
widthForScrollBetween:firstLine and:lastLine
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   369
    "return the width in pixels for a scroll between firstLine and lastLine"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   370
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   371
    selectionStartLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   372
	(lastLine < selectionStartLine) ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   373
	    (firstLine > selectionEndLine) ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   374
		^ width
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   375
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   376
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   377
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   378
    ^ super widthForScrollBetween:firstLine and:lastLine
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   379
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   380
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   381
scrollSelectUp
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   382
    "auto scroll action; scroll and reinstall timed-block"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   383
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   384
    |prevStartLine|
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   385
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   386
    "just to make certain ..."
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   387
    selectionStartLine isNil ifTrue:[^ self].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   388
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   389
    self scrollUp.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   390
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   391
    "make new selection immediately visible"
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   392
    prevStartLine := selectionStartLine.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   393
    selectionStartLine := firstLineShown.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   394
    selectionStartCol := 1.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   395
    selectionStartLine to:prevStartLine do:[:lineNr |
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   396
	self redrawLine:lineNr
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   397
    ].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   398
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   399
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   400
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   401
scrollSelectDown
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   402
    "auto scroll action; scroll and reinstall timed-block"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   403
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   404
    |prevEndLine|
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   405
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   406
    "just to make certain ..."
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   407
    selectionEndLine isNil ifTrue:[^ self].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   408
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   409
    self scrollDown.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   410
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   411
    "make new selection immediately visible"
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   412
    prevEndLine := selectionEndLine.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   413
    selectionEndLine := firstLineShown + nFullLinesShown.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   414
    selectionEndCol := 0.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   415
    prevEndLine to:selectionEndLine do:[:lineNr |
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   416
	self redrawLine:lineNr
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   417
    ].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   418
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   419
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   420
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   421
stopScrollSelect
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   422
    "stop auto scroll; deinstall timed-block"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   423
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   424
    autoScrollBlock notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   425
	Processor removeTimedBlock:autoScrollBlock.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   426
	self compressMotionEvents:true.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   427
	autoScrollBlock := nil.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   428
	autoScrollDeltaT := nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   429
    ]
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   430
!
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   431
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   432
scrollSelectLeft
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   433
    "auto scroll action; scroll and reinstall timed-block"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   434
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   435
    |prevStartLine|
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   436
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   437
    "just to make certain ..."
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   438
    selectionStartLine isNil ifTrue:[^ self].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   439
    selectionStartCol isNil ifTrue:[^ self].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   440
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   441
    "make new selection immediately visible"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   442
    prevStartLine := selectionStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   443
    selectionStartCol := selectionStartCol - 1 max:1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   444
    self scrollLeft.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   445
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   446
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   447
!
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   448
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   449
scrollSelectRight
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   450
    "auto scroll action; scroll and reinstall timed-block"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   451
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   452
    |prevEndCol|
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   453
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   454
    "just to make certain ..."
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   455
    selectionEndCol isNil ifTrue:[^ self].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   456
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   457
    prevEndCol := selectionEndCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   458
    selectionEndCol := selectionEndCol + 1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   459
    self scrollRight.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   460
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   461
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   462
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   463
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   464
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   465
!TextView methodsFor:'menu actions'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   466
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   467
print
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   468
    "print the contents on the printer"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   469
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   470
    |printStream|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   471
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   472
    list isNil ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   473
    printStream := Printer new.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   474
    printStream notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   475
	self fileOutContentsOn:printStream.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   476
	printStream close
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   477
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   478
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   479
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   480
saveAs:fileName
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   481
    "save contents into a file named fileName"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   482
 
3
claus
parents: 0
diff changeset
   483
    |aStream msg|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   484
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   485
    aStream := FileStream newFileNamed:fileName.
3
claus
parents: 0
diff changeset
   486
    aStream isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   487
	msg := resources string:'cannot write file %1 !!' with:fileName.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   488
	self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
3
claus
parents: 0
diff changeset
   489
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   490
	self fileOutContentsOn:aStream.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   491
	aStream close.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   492
	contentsWasSaved := true
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   493
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   494
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   495
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   496
appendTo:fileName
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   497
    "append contents to a file named fileName"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   498
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   499
    |aStream msg|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   500
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   501
    aStream := FileStream appendingOldFileNamed:fileName.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   502
    aStream isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   503
	msg := resources string:'cannot append to file %1 !!' with:fileName.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   504
	self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   505
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   506
	self fileOutContentsOn:aStream.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   507
	aStream close.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   508
	contentsWasSaved := true
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   509
    ]
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   510
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   511
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   512
save
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   513
    "save contents into a file 
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   514
     - ask user for filename using a fileSelectionBox."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   515
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   516
    fileBox isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   517
	fileBox := FileSaveBox
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   518
			title:(resources string:'save contents in:')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   519
			okText:(resources string:'save')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   520
			abortText:(resources string:'cancel')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   521
			action:[:fileName | self saveAs:fileName].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   522
	fileBox appendAction:[:fileName | self appendTo:fileName].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   523
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   524
    directoryForFileDialog notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   525
	fileBox directory:directoryForFileDialog
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   526
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   527
    fileBox showAtPointer
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   528
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   529
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   530
copySelection
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   531
    "copy contents into smalltalk copybuffer"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   532
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   533
    |text|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   534
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   535
    text := self selection.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   536
    text notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   537
	Smalltalk at:#CopyBuffer put:text.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   538
	self unselect
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   539
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   540
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   541
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   542
changeFont
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   543
    "pop up a fontPanel to change font"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   544
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   545
    MyFontPanel isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   546
	MyFontPanel := FontPanel new
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   547
    ].
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   548
    MyFontPanel action:[:family :face :style :size |
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   549
	self font:(Font family:family
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   550
			  face:face
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   551
			 style:style
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   552
			  size:size)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   553
    ].
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   554
    MyFontPanel initialFont:font.
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   555
    MyFontPanel showAtPointer
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   556
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   557
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   558
defaultForGotoLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   559
    "return a default value to show in the gotoLine box"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   560
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   561
    ^ nil
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   562
!
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   563
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   564
gotoLine
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   565
    "show a box to enter lineNumber for positioning"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   566
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   567
    |l|
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   568
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   569
    lineNumberBox isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   570
	lineNumberBox :=
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   571
	    EnterBox
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   572
	       title:(resources string:'line number:')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   573
	      okText:(resources string:'goto')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   574
	   abortText:(resources string:'cancel')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   575
	      action:[:l | self gotoLine:(Number readFromString:l)]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   576
    ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   577
    l := self defaultForGotoLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   578
    l notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   579
	l := l printString
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   580
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   581
    lineNumberBox initialText:l .
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   582
    lineNumberBox showAtPointer
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   583
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   584
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   585
!TextView methodsFor:'selections'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   586
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   587
enableOrDisableSelectionMenuEntries
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   588
    "sent internally, whenever selection status changes to
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   589
     update menu entries"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   590
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   591
    self hasSelection ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   592
	self disableSelectionMenuEntries
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   593
    ] ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   594
	self enableSelectionMenuEntries
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   595
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   596
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   597
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   598
disableSelectionMenuEntries
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   599
    "disable relevant menu entries when no selection is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   600
     available - redefined in subclasses to disable more,
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   601
     but do NOT forget a super disableSelectionMenuEntries there."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   602
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   603
    middleButtonMenu notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   604
	middleButtonMenu disable:#copySelection
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   605
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   606
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   607
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   608
enableSelectionMenuEntries
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   609
    "disable relevant menu entries when a selection is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   610
     available - redefined in subclasses to enable more,
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   611
     but do NOT forget a super enableSelectionMenuEntries there."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   612
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   613
    middleButtonMenu notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   614
	middleButtonMenu enable:#copySelection
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   615
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   616
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   617
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   618
unselectWithoutRedraw
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   619
    "forget selection but do not redraw the selection area
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   620
     - can be done when selected area is redrawn anyway or
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   621
     known to be invisible."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   622
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   623
    selectionStartLine := nil.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   624
    self disableSelectionMenuEntries
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   625
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   626
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   627
unselect
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   628
    "unselect - if there was a selection redraw that area"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   629
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   630
    |startLine endLine startVisLine endVisLine|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   631
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   632
    selectionStartLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   633
	startLine := selectionStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   634
	endLine := selectionEndLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   635
	selectionStartLine := nil.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   636
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   637
	"if selection is not visible, we are done"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   638
	startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   639
	endLine < firstLineShown ifTrue:[^ self].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   640
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   641
	startLine < firstLineShown ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   642
	    startVisLine := 1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   643
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   644
	    startVisLine := self listLineToVisibleLine:startLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   645
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   646
	endLine >= (firstLineShown + nLinesShown) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   647
	    endVisLine := nLinesShown
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   648
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   649
	    endVisLine := self listLineToVisibleLine:endLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   650
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   651
	"if its only part of a line, just redraw what has to be"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   652
	(startVisLine == endVisLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   653
	    super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   654
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   655
	    super redrawFromVisibleLine:startVisLine to:endVisLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   656
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   657
	self unselectWithoutRedraw
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   658
    ].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   659
    selectStyle := nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   660
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   661
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   662
selectFromLine:startLine col:startCol toLine:endLine col:endCol
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   663
    "select a piece of text and redraw that area"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   664
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   665
    self unselect.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   666
    startLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   667
	"new:"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   668
	endLine < startLine ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   669
	    ^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   670
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   671
	(endLine == startLine and:[endCol < startCol]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   672
	    ^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   673
	].
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   674
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   675
" old:
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   676
	endLine < startLine ifTrue:[^ self].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   677
	(startLine == endLine and:[endCol < startCol]) ifTrue:[^ self].
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   678
"
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   679
	selectionStartLine := startLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   680
	selectionStartCol := startCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   681
	selectionEndLine := endLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   682
	selectionEndCol := endCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   683
	(startLine == endLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   684
	    self redrawLine:startLine from:startCol to:endCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   685
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   686
	    startLine to:endLine do:[:lineNr |
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   687
		self redrawLine:lineNr
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   688
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   689
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   690
	selectStyle := nil.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   691
	self enableSelectionMenuEntries
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   692
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   693
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   694
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   695
selectLine:selectLine
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   696
    "select one line and redraw it"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   697
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   698
    self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   699
    wordStartCol := selectionStartCol.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   700
    wordEndCol := selectionEndCol.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   701
    wordStartLine := selectionStartLine.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   702
    wordEndLine := selectionEndLine.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   703
    selectStyle := #line
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   704
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   705
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   706
selectLineWhereCharacterPosition:pos
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   707
    "select the line, where characterPosition pos is living.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   708
     The argument pos starts at 1 from the start of the text
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   709
     and counts characters (i.e. can be used to convert from 
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   710
     character position within a string to line-position in view)."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   711
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   712
    self selectLine:(self lineOfCharacterPosition:pos)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   713
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   714
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   715
selectFromCharacterPosition:pos1 to:pos2
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   716
    "compute line/col from character positions and select the text"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   717
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   718
    |line1 col1 line2 col2|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   719
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   720
    line1 := self lineOfCharacterPosition:pos1.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   721
    col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   722
    line2 := self lineOfCharacterPosition:pos2.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   723
    col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   724
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   725
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   726
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   727
wordAtLine:selectLine col:selectCol do:aFiveArgBlock
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   728
    "find word boundaries, evaluate the block argument with those.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   729
     A helper for nextWord and selectWord functions."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   730
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   731
    |beginCol endCol endLine thisCharacter flag|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   732
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   733
    flag := #word.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   734
    beginCol := selectCol.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   735
    endCol := selectCol.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   736
    endLine := selectLine.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   737
    thisCharacter := self characterAtLine:selectLine col:beginCol.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   738
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   739
    beginCol := self findBeginOfWordAtLine:selectLine col:selectCol.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   740
    endCol := self findEndOfWordAtLine:selectLine col:selectCol.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   741
    endCol == 0 ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   742
	endLine := selectLine + 1
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   743
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   744
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   745
    "is the initial acharacter within a word ?"
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   746
    (wordCheck value:thisCharacter) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   747
	"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   748
	 try to catch a blank ...
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   749
	"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   750
	((beginCol == 1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   751
	or:[(self characterAtLine:selectLine col:(beginCol - 1))
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   752
	     ~~ Character space]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   753
	    ((self characterAtLine:selectLine col:(endCol + 1))
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   754
	      == Character space) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   755
		endCol := endCol + 1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   756
		flag := #wordRight
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   757
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   758
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   759
	    beginCol := beginCol - 1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   760
	    flag := #wordLeft
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   761
	].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   762
    ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   763
    aFiveArgBlock value:selectLine 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   764
		  value:beginCol 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   765
		  value:endLine 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   766
		  value:endCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   767
		  value:flag
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   768
!
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   769
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   770
selectWordAtLine:line col:col
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   771
    "select the word at given line/col"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   772
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   773
    self wordAtLine:line col:col do:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   774
	:beginLine :beginCol :endLine :endCol :style |
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   775
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   776
	self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   777
	selectStyle := style
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   778
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   779
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   780
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   781
selectWordAtX:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   782
    "select the word at given x/y-(view-)coordinate"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   783
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   784
    |selectVisibleLine selectLine selectCol|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   785
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   786
    selectStyle := nil.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   787
    selectVisibleLine := self visibleLineOfY:y.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   788
    selectLine := self visibleLineToListLine:selectVisibleLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   789
    selectLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   790
	selectCol := self colOfX:x inVisibleLine:selectLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   791
	self selectWordAtLine:selectLine col:selectCol
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   792
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   793
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   794
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   795
selectLineAtY:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   796
    "select the line at given y-(view-)coordinate"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   797
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   798
    |selectVisibleLine selectLine|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   799
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   800
    selectVisibleLine := self visibleLineOfY:y.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   801
    selectLine := self visibleLineToListLine:selectVisibleLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   802
    selectLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   803
	self selectLine:selectLine
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   804
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   805
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   806
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   807
selectAll
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   808
    "select the whole text"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   809
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   810
    self selectFromLine:1 col:1 toLine:(list size + 1) col:0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   811
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   812
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   813
hasSelection
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   814
    "return true, if there is a selection"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   815
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   816
    ^ selectionStartLine notNil
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   817
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   818
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   819
selection
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   820
    "return the selection as a collection of (line-)strings"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   821
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   822
    |text sz index|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   823
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   824
    selectionStartLine isNil ifTrue:[^ nil].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   825
    (selectionStartLine == selectionEndLine) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   826
	"part of a line"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   827
	^ Text with:(self listAt:selectionStartLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   828
			    from:selectionStartCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   829
			      to:selectionEndCol)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   830
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   831
    sz := selectionEndLine - selectionStartLine + 1.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   832
    text := Text new:sz.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   833
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   834
    "get 1st and last (possibly) partial lines"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   835
    text at:1 put:(self listAt:selectionStartLine from:selectionStartCol).
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   836
selectionEndCol == 0 ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   837
    text at:sz put:''
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   838
] ifFalse:[
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   839
    text at:sz put:(self listAt:selectionEndLine to:selectionEndCol).
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   840
].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   841
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   842
    "get bulk of text"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   843
    index := 2.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   844
    (selectionStartLine + 1) to:(selectionEndLine - 1) do:[:lineNr |
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   845
	text at:index put:(self listAt:lineNr).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   846
	index := index + 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   847
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   848
    ^ text
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   849
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   850
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   851
makeSelectionVisible
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   852
    "scroll to make selection visible"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   853
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   854
    selectionStartLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   855
	self makeLineVisible:selectionStartLine
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   856
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   857
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   858
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   859
!TextView methodsFor:'searching'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   860
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   861
search
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   862
    "show a box to enter searchpattern 
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   863
     - currently no regular expressions are handled."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   864
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   865
    "
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   866
     cache the searchBox
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   867
     Q: should we use one global searchBox for all textViews ?
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   868
	(we could then preserve the last searchstring between views)
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   869
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   870
    searchBox isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   871
	searchBox :=
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   872
	    EnterBox2
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   873
	       title:(resources at:'searchPattern:')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   874
	     okText1:(resources at:'prev')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   875
	     okText2:(resources at:'next')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   876
	   abortText:(resources at:'cancel')
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   877
	     action1:[:pattern | self searchBwd:(pattern withoutSeparators)]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   878
	     action2:[:pattern | self searchFwd:(pattern withoutSeparators)]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   879
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   880
    searchPattern notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   881
	searchBox initialText:searchPattern
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   882
    ].
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   883
    self hasSelection ifTrue:[
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   884
	selectionStartLine == selectionEndLine ifTrue:[
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   885
	    searchBox initialText:self selection
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   886
	]
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   887
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   888
    searchBox showAtPointer
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   889
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   890
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   891
setSearchPattern:aString
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   892
    "set the searchpattern for future searches"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   893
70
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
   894
    aString isNil ifTrue:[
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
   895
	searchPattern := aString
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
   896
    ] ifFalse:[
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
   897
	searchPattern := aString withoutSeparators
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
   898
    ]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   899
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   900
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   901
setSearchPattern
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   902
    "set the searchpattern from the selection if there is one"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   903
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   904
    |sel|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   905
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   906
    sel := self selection.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   907
    sel notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   908
	searchPattern := sel asString withoutSeparators
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   909
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   910
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   911
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   912
searchPattern
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   913
    "return the last search pattern"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   914
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   915
    ^ searchPattern
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   916
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   917
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   918
showNotFound
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   919
    "search not found - tell user by beeping and changing
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   920
     cursor for a while (sometimes I work with a headset :-)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   921
     (used to be: tell user by changing cursor for a while)"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   922
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   923
    |savedCursor|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   924
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   925
    device beep.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   926
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   927
    uncomment if you want a CROSS cursor to be shown for a while ..
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   928
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   929
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   930
" "
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   931
    savedCursor := cursor.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   932
    self cursor:(Cursor cross).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   933
    OperatingSystem millisecondDelay:300.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   934
    self cursor:savedCursor
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   935
" "
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   936
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   937
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   938
searchFwd
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   939
    "search forward for pattern or selection"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   940
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   941
    selectStyle == #wordLeft ifTrue:[
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   942
	"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   943
	 remove the space from the selection
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   944
	"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   945
	selectionStartCol := selectionStartCol + 1.
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   946
	super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1.
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   947
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   948
    self setSearchPattern.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   949
    searchPattern notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   950
	self searchFwd:searchPattern
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   951
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   952
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   953
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   954
searchBwd
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   955
    "search backward and -if found- position cursor"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   956
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   957
    self setSearchPattern.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   958
    searchPattern notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   959
	self searchBwd:searchPattern
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   960
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   961
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   962
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   963
searchFwd:pattern
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   964
    "do a forward search"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   965
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   966
    self searchFwd:pattern ifAbsent:[self showNotFound].
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   967
    searchPattern := pattern
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   968
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   969
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   970
searchBwd:pattern
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   971
    "do a backward search"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   972
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   973
    self searchBwd:pattern ifAbsent:[self showNotFound].
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   974
    searchPattern := pattern
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   975
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   976
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   977
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   978
searchFwd:pattern ifAbsent:aBlock
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   979
    "do a forward search"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   980
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   981
    |startLine startCol|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   982
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   983
    selectionStartLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   984
	startLine := selectionStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   985
	startCol := selectionStartCol
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   986
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   987
	startLine := 1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   988
	startCol := 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   989
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   990
    self searchForwardFor:pattern startingAtLine:startLine col:startCol
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   991
    ifFound:[:line :col |
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   992
	self selectFromLine:line col:col
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   993
		     toLine:line col:(col + pattern size - 1).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   994
	self makeLineVisible:line
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   995
    ] ifAbsent:aBlock
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   996
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   997
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   998
searchBwd:pattern ifAbsent:aBlock
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   999
    "do a backward search"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1000
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1001
    |startLine startCol|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1002
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1003
    selectionStartLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1004
	startLine := selectionStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1005
	startCol := selectionStartCol
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1006
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1007
	startLine := 1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1008
	startCol := 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1009
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1010
    self searchBackwardFor:pattern startingAtLine:startLine col:startCol
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1011
    ifFound:[:line :col |
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1012
	self selectFromLine:line col:col
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1013
		     toLine:line col:(col + pattern size - 1).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1014
	self makeLineVisible:line
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
  1015
    ] ifAbsent:aBlock
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1016
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1017
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1018
!TextView methodsFor:'redrawing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1019
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1020
clearMarginOfVisible:visLine with:color
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1021
    "if there is a margin, clear it - a helper for selection drawing"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1022
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1023
    (leftMargin ~~ 0) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1024
	self paint:color.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1025
	self fillRectangleX:margin
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1026
			  y:(self yOfVisibleLine:visLine)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1027
		      width:leftMargin
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1028
		     height:fontHeight
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1029
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1030
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1031
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1032
redrawVisibleLine:visLine col:col
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1033
    "redraw single character at col in visible line lineNr"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1034
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1035
    |line|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1036
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1037
    line := self visibleLineToAbsoluteLine:visLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1038
    selectionStartLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1039
	(line between:selectionStartLine and:selectionEndLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1040
	    ((line == selectionStartLine)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1041
	    and: [col < selectionStartCol]) ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1042
		((line == selectionEndLine)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1043
		and: [col > selectionEndCol]) ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1044
		    "its in the selection"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1045
		    self drawVisibleLine:visLine col:col with:selectionFgColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1046
							  and:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1047
		    ^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1048
		]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1049
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1050
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1051
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1052
    super redrawVisibleLine:visLine col:col
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1053
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1054
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1055
redrawFromVisibleLine:startVisLineNr to:endVisLineNr
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1056
    "redraw a visible line range"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1057
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1058
    |startLine endLine specialCare end selVisStart line1 line2|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1059
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1060
    shown ifFalse:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1061
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1062
    end := endVisLineNr.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1063
    (end > nLinesShown) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1064
	end := nLinesShown
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1065
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1066
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1067
    selectionStartLine isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1068
	specialCare := false
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1069
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1070
	startLine := self visibleLineToAbsoluteLine:startVisLineNr.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1071
	(startLine > selectionEndLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1072
	    specialCare := false
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1073
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1074
	    endLine := self visibleLineToAbsoluteLine:end.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1075
	    (endLine < selectionStartLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1076
		specialCare := false
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1077
	    ] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1078
		specialCare := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1079
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1080
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1081
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1082
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1083
    "easy: nothing is selected"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1084
    specialCare ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1085
	super redrawFromVisibleLine:startVisLineNr to:end.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1086
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1087
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1088
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1089
    "easy: all is selected"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1090
    ((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1091
	self drawFromVisibleLine:startVisLineNr to:end with:selectionFgColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1092
							and:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1093
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1094
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1095
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1096
    (selectionStartLine >= firstLineShown) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1097
	"draw unselected top part"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1098
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1099
	selVisStart := self listLineToVisibleLine:selectionStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1100
	super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1101
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1102
	"and first partial selected line"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1103
	self redrawVisibleLine:selVisStart.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1104
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1105
	"rest starts after this one"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1106
	line1 := selVisStart + 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1107
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1108
	line1 := 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1109
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1110
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1111
    (line1 > end) ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1112
    (line1 < startVisLineNr) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1113
	line1 := startVisLineNr
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1114
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1115
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1116
    "draw middle part of selection"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1117
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1118
    (selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1119
	line2 := nLinesShown
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1120
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1121
	line2 := (self listLineToVisibleLine:selectionEndLine) - 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1122
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1123
    (line2 > end) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1124
	line2 := end
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1125
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1126
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1127
    self drawFromVisibleLine:line1 to:line2 with:selectionFgColor
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1128
					     and:selectionBgColor.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1129
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1130
    (line2 >= end) ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1131
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1132
    "last line of selection"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1133
    self redrawVisibleLine:(line2 + 1).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1134
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1135
    ((line2 + 2) <= end) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1136
	super redrawFromVisibleLine:(line2 + 2) to:end
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1137
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1138
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1139
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1140
redrawVisibleLine:visLine
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1141
    "redraw visible line lineNr"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1142
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1143
    |len line l|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1144
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1145
    selectionStartLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1146
	line := self visibleLineToAbsoluteLine:visLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1147
	(line between:selectionStartLine and:selectionEndLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1148
	    (line == selectionStartLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1149
		(line == selectionEndLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1150
		    "its part-of-single-line selection"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1151
		    self clearMarginOfVisible:visLine with:bgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1152
		    (selectionStartCol > 1) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1153
			super redrawVisibleLine:visLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1154
					   from:1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1155
					     to:(selectionStartCol - 1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1156
		    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1157
		    self drawVisibleLine:visLine from:selectionStartCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1158
						   to:selectionEndCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1159
						 with:selectionFgColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1160
						  and:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1161
		    super redrawVisibleLine:visLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1162
				       from:(selectionEndCol + 1).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1163
		    ^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1164
		].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1165
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1166
		"its the first line of a multi-line selection"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1167
		(selectionStartCol ~~ 1) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1168
		    self clearMarginOfVisible:visLine with:bgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1169
		    super redrawVisibleLine:visLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1170
				       from:1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1171
					 to:(selectionStartCol - 1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1172
		].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1173
		self drawVisibleLine:visLine from:selectionStartCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1174
				with:selectionFgColor and:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1175
		^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1176
	    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1177
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1178
	    (line == selectionEndLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1179
		"its the last line of a multi-line selection"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1180
		(selectionEndCol == 0) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1181
		    ^ super redrawVisibleLine:visLine
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1182
		].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1183
		l := self visibleAt:selectionEndLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1184
		len := l size.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1185
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1186
		self clearMarginOfVisible:visLine with:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1187
		self drawVisibleLine:visLine from:1 to:selectionEndCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1188
				with:selectionFgColor and:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1189
		super redrawVisibleLine:visLine from:(selectionEndCol + 1).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1190
		^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1191
	    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1192
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1193
	    "its a full line in a multi-line selection"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1194
	    self clearMarginOfVisible:visLine with:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1195
	    self drawVisibleLine:visLine with:selectionFgColor and:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1196
	    ^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1197
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1198
    ].
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1199
    super redrawVisibleLine:visLine
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1200
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1201
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1202
redrawVisibleLine:visLine from:startCol
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1203
    "redraw visible line lineNr from startCol to end of line"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1204
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1205
    |line|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1206
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1207
    line := self visibleLineToAbsoluteLine:visLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1208
    selectionStartLine notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1209
	(line between:selectionStartLine and:selectionEndLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1210
	    ((line == selectionStartLine) 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1211
	     or:[line == selectionEndLine]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1212
		"since I'm lazy, redraw full line"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1213
		self redrawVisibleLine:visLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1214
		^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1215
	    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1216
	    "the line is fully within the selection"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1217
	    self drawVisibleLine:visLine from:startCol with:selectionFgColor
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1218
							and:selectionBgColor.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1219
	    ^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1220
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1221
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1222
    super redrawVisibleLine:visLine from:startCol
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1223
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1224
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1225
redrawVisibleLine:visLine from:startCol to:endCol
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1226
    "redraw visible line lineNr from startCol to endCol"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1227
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1228
    |line allOut allIn leftCol rightCol|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1229
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1230
    line := self visibleLineToAbsoluteLine:visLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1231
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1232
    allIn := false.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1233
    allOut := false.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1234
    selectionStartLine isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1235
	allOut := true
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1236
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1237
	(line between:selectionStartLine and:selectionEndLine) ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1238
	    allOut := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1239
	] ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1240
	    (selectionStartLine == selectionEndLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1241
		((endCol < selectionStartCol) 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1242
		or:[startCol > selectionEndCol]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1243
		    allOut := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1244
		] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1245
		    ((startCol >= selectionStartCol) 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1246
		    and:[endCol <= selectionEndCol]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1247
			allIn := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1248
		    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1249
		]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1250
	    ] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1251
		(line == selectionStartLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1252
		    (endCol < selectionStartCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1253
			allOut := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1254
		    ] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1255
			(startCol >= selectionStartCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1256
			    allIn := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1257
			]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1258
		    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1259
		] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1260
		    (line == selectionEndLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1261
			(startCol > selectionEndCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1262
			    allOut := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1263
			] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1264
			    (endCol <= selectionEndCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1265
				allIn := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1266
			    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1267
			]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1268
		    ] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1269
			allIn := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1270
		    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1271
		]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1272
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1273
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1274
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1275
    allOut ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1276
	super redrawVisibleLine:visLine from:startCol to:endCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1277
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1278
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1279
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1280
    allIn ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1281
	self drawVisibleLine:visLine from:startCol to:endCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1282
			with:selectionFgColor and:selectionBgColor
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1283
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1284
	"redraw part before selection"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1285
	((line == selectionStartLine)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1286
	 and:[startCol <= selectionStartCol]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1287
	    super redrawVisibleLine:visLine from:startCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1288
					      to:(selectionStartCol - 1).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1289
	    leftCol := selectionStartCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1290
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1291
	    leftCol := startCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1292
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1293
	"redraw selected part"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1294
	(selectionEndLine > line) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1295
	    rightCol := endCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1296
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1297
	    rightCol := selectionEndCol min:endCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1298
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1299
	self drawVisibleLine:visLine from:leftCol to:rightCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1300
			with:selectionFgColor and:selectionBgColor.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1301
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1302
	"redraw part after selection"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1303
	(rightCol < endCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1304
	    super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1305
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1306
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1307
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1308
    "special care for first and last line of selection:
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1309
     must handle margin also"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1310
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1311
    ((line == selectionEndLine)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1312
    and:[(startCol == 1)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1313
    and:[selectionStartLine < selectionEndLine]])
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1314
    ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1315
	self clearMarginOfVisible:visLine with:selectionBgColor.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1316
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1317
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1318
    ((line == selectionStartLine)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1319
    and:[(startCol == 1)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1320
    and:[selectionStartLine < selectionEndLine]])
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1321
    ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1322
	self clearMarginOfVisible:visLine with:bgColor.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1323
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1324
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1325
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1326
!TextView methodsFor:'event processing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1327
45
e900c30938c8 *** empty log message ***
claus
parents: 38
diff changeset
  1328
mapped 
e900c30938c8 *** empty log message ***
claus
parents: 38
diff changeset
  1329
    super mapped.
e900c30938c8 *** empty log message ***
claus
parents: 38
diff changeset
  1330
    selectionFgColor := selectionFgColor on:device.
e900c30938c8 *** empty log message ***
claus
parents: 38
diff changeset
  1331
    selectionBgColor := selectionBgColor on:device.
e900c30938c8 *** empty log message ***
claus
parents: 38
diff changeset
  1332
!
e900c30938c8 *** empty log message ***
claus
parents: 38
diff changeset
  1333
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1334
keyPress:key x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1335
    "handle some keyboard input (there is not much to be done here)"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1336
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1337
    (key == #Find) ifTrue:[self search. ^self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1338
    (key == #Copy) ifTrue:[self copySelection. ^self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1339
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1340
    (key == #FindNext) ifTrue:[self searchFwd. ^self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1341
    (key == #FindPrev) ifTrue:[self searchBwd. ^self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1342
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1343
    (key == #SelectAll) ifTrue:[self selectAll. ^self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1344
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1345
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1346
     shift-Fn defines a key-sequence 
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1347
     Fn       pastes that sequence
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1348
     cmd-Fn   performs a 'doIt' on the sequence (Workspaces only)
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1349
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1350
     (see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y)
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1351
    "
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1352
    (#(F1 F2 F3 F4 F5 F6 F7 F8 F9) includes:key) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1353
	device shiftDown ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1354
	    (Smalltalk at:#FunctionKeySequences) isNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1355
		Smalltalk at:#FunctionKeySequences put:Dictionary new
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1356
	    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1357
	    (Smalltalk at:#FunctionKeySequences) at:key put:(self selection)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1358
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1359
	^ self
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1360
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1361
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1362
    super keyPress:key x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1363
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1364
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1365
buttonPress:button x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1366
    "mouse-click - prepare for selection change"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1367
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1368
    |clickVisibleLine|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1369
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1370
    ((button == 1) or:[button == #select]) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1371
	clickVisibleLine := self visibleLineOfY:y.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1372
	clickCol := self colOfX:x inVisibleLine:clickVisibleLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1373
	clickLine := self visibleLineToAbsoluteLine:clickVisibleLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1374
	clickStartLine := clickLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1375
	clickStartCol := clickCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1376
	self unselect.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1377
	clickCount := 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1378
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1379
	super buttonPress:button x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1380
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1381
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1382
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1383
buttonShiftPress:button x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1384
    "mouse-click with shift - adding to selection"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1385
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1386
    "very simple - just simulate a move"
53
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
  1387
    ^ self buttonMotion:(device button1MotionMask) x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1388
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1389
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1390
buttonMultiPress:button x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1391
    "multi-mouse-click - select word under pointer"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1392
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1393
    ((button == 1) or:[button == #select]) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1394
	clickCount notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1395
	    clickCount := clickCount + 1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1396
	    (clickCount == 2) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1397
		self selectWordAtX:x y:y.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1398
		"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1399
		 remember words position in case of a drag following
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1400
		"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1401
		wordStartLine := selectionStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1402
		wordEndLine := selectionEndLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1403
		selectStyle == #wordLeft ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1404
		    wordStartCol := selectionStartCol + 1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1405
		] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1406
		    wordStartCol := selectionStartCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1407
		].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1408
		selectStyle == #wordRight ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1409
		    wordEndCol := selectionEndCol - 1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1410
		] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1411
		    wordEndCol := selectionEndCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1412
		]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1413
	    ] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1414
		(clickCount == 3) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1415
		    self selectLineAtY:y.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1416
		    selectStyle := #line
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1417
		] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1418
		    (clickCount == 4) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1419
			self selectAll
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1420
		    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1421
		]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1422
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1423
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1424
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1425
	super buttonMultiPress:button x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1426
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1427
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1428
53
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
  1429
buttonMotion:buttonMask x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1430
    "mouse-move while button was pressed - handle selection changes"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1431
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1432
    |movedVisibleLine movedLine movedCol 
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1433
     movedUp 
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1434
     oldStartLine oldEndLine oldStartCol oldEndCol|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1435
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1436
    clickLine isNil ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1437
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
  1438
    "is it the select or 1-button ?"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
  1439
    (device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
  1440
	(device buttonMotionMask:buttonMask includesButton:1) ifFalse:[
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
  1441
	    ^ self
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
  1442
	].
53
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
  1443
    ].
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
  1444
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1445
    "if moved outside of view, start autoscroll"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1446
    (y < 0) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1447
	self compressMotionEvents:false.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1448
	self startAutoScrollUp:y.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1449
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1450
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1451
    (y > height) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1452
	self compressMotionEvents:false.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1453
	self startAutoScrollDown:(y - height).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1454
	^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1455
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1456
    ((x < 0) and:[leftOffset ~~ 0]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1457
	self compressMotionEvents:false.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1458
	self startAutoScrollLeft:x.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1459
	^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1460
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1461
    (x > width) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1462
	self compressMotionEvents:false.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1463
	self startAutoScrollRight:(x - width).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1464
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1465
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1466
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1467
    "move inside - stop autoscroll if any"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1468
    autoScrollBlock notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1469
	self stopScrollSelect
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1470
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1471
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1472
    movedVisibleLine := self visibleLineOfY:y.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1473
    movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1474
    (x < leftMargin) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1475
	movedCol := 0
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1476
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1477
	movedCol := self colOfX:x inVisibleLine:movedVisibleLine
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1478
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1479
    ((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1480
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1481
    selectionStartLine isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1482
	selectionStartLine := clickLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1483
	selectionStartCol := clickCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1484
	selectionEndLine := selectionStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1485
	selectionEndCol := selectionStartCol
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1486
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1487
    oldStartLine := selectionStartLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1488
    oldEndLine := selectionEndLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1489
    oldStartCol := selectionStartCol.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1490
    oldEndCol := selectionEndCol.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1491
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1492
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1493
    "find out if we are before or after initial click"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1494
    movedUp := false.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1495
    (movedLine < clickStartLine) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1496
	movedUp := true
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1497
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1498
	(movedLine == clickStartLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1499
	    (movedCol < clickStartCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1500
		movedUp := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1501
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1502
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1503
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1504
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1505
    movedUp ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1506
	"change selectionStart"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1507
	selectionStartCol := movedCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1508
	selectionStartLine := movedLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1509
	selectionEndCol := clickStartCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1510
	selectionEndLine := clickStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1511
	selectStyle notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1512
	    selectionEndCol := wordEndCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1513
	    selectionEndLine := wordEndLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1514
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1515
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1516
	"change selectionEnd"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1517
	selectionEndCol := movedCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1518
	selectionEndLine := movedLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1519
	selectionStartCol := clickStartCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1520
	selectionStartLine := clickStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1521
	selectStyle notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1522
	    selectionStartCol := wordStartCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1523
	    selectionStartLine := wordStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1524
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1525
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1526
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1527
    (selectionStartCol == 0) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1528
	selectionStartCol := 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1529
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1530
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1531
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1532
     if in word-select, just catch the rest of the word
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1533
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1534
    (selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1535
	movedUp ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1536
	    selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1537
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1538
	    selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1539
	    selectionEndCol == 0 ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1540
		selectionEndLine := selectionEndLine + 1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1541
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1542
	].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1543
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1544
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1545
    selectStyle == #line ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1546
	movedUp ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1547
	    selectionStartCol := 1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1548
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1549
	    selectionEndCol := 0.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1550
	    selectionEndLine := selectionEndLine + 1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1551
	]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1552
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1553
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1554
    (oldStartLine == selectionStartLine) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1555
	(oldStartCol ~~ selectionStartCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1556
	    self redrawLine:oldStartLine 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1557
		       from:((selectionStartCol min:oldStartCol) max:1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1558
			 to:((selectionStartCol max:oldStartCol) max:1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1559
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1560
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1561
	self redrawFromLine:(oldStartLine min:selectionStartLine)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1562
			 to:(oldStartLine max:selectionStartLine)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1563
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1564
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1565
    (oldEndLine == selectionEndLine) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1566
	(oldEndCol ~~ selectionEndCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1567
	    self redrawLine:oldEndLine 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1568
		       from:((selectionEndCol min:oldEndCol) max:1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1569
			 to:((selectionEndCol max:oldEndCol) max:1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1570
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1571
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1572
	self redrawFromLine:(oldEndLine min:selectionEndLine)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1573
			 to:(oldEndLine max:selectionEndLine)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1574
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1575
    clickLine := movedLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1576
    clickCol := movedCol
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1577
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1578
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1579
buttonRelease:button x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1580
    "mouse- button release - turn off autoScroll if any"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1581
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
  1582
    ((button == 1) or:[button == #select]) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1583
	autoScrollBlock notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1584
	    self stopScrollSelect
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1585
	].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1586
	self enableOrDisableSelectionMenuEntries.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1587
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1588
	super buttonRelease:button x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1589
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1590
! !