TextView.st
author Claus Gittinger <cg@exept.de>
Tue, 21 Oct 1997 20:03:18 +0200
changeset 1353 5dac6aa6ac96
parent 1349 09db5ecfb437
child 1359 d1d0c157a85f
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
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
    13
'From Smalltalk/X, Version:3.2.1 on 20-oct-1997 at 2:11:29 pm'                  !
1349
09db5ecfb437 catch file errors when saving
Claus Gittinger <cg@exept.de>
parents: 1337
diff changeset
    14
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
ListView subclass:#TextView
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
    16
	instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    17
		selectionEndCol clickStartLine clickStartCol clickLine clickCol
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    18
		clickCount expandingTop wordStartCol wordStartLine wordEndCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    19
		wordEndLine selectionFgColor selectionBgColor selectStyle
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
    20
		directoryForFileDialog defaultFileNameForFileDialog
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
    21
		externalEncoding contentsWasSaved'
392
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    22
	classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
    23
		DefaultSelectionBackgroundColor MatchDelayTime
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    24
		WordSelectCatchesBlanks ST80Selections'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
    25
	poolDictionaries:''
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
    26
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    27
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    28
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    29
!TextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    30
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    31
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    32
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    33
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
    34
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    35
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    36
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    37
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    38
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    39
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    40
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    41
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    42
"
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
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
    45
documentation
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    46
"
120
claus
parents: 119
diff changeset
    47
    a view for readOnly text - this class adds selections to a simple list.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    48
    The text is not editable and there is no cursor.
120
claus
parents: 119
diff changeset
    49
    Use TextViews for readonly text, EditTextView for editable text.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    50
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    51
    Please read the historic notice in the ListView class.
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    52
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    53
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    54
120
claus
parents: 119
diff changeset
    55
      selectionStartLine      <Number>                the line of the selection start (or nil)
claus
parents: 119
diff changeset
    56
      selectionStartCol       <Number>                the col of the selection start
claus
parents: 119
diff changeset
    57
      selectionEndLine        <Number>                the line of the selection end
claus
parents: 119
diff changeset
    58
      selectionEndCol         <Number>                the col of the selection end
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    59
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    60
      clickStartLine          <Number>                temporary - remember where select operation started
120
claus
parents: 119
diff changeset
    61
      clickStartCol           <Number>                temporary
claus
parents: 119
diff changeset
    62
      clickLine               <Number>                temporary
claus
parents: 119
diff changeset
    63
      clickCol                <Number>                temporary
claus
parents: 119
diff changeset
    64
      clickCount              <Number>                temporary
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    65
      expandingTop            <Boolean>               temporary - for expandSelection
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    66
120
claus
parents: 119
diff changeset
    67
      selectionFgColor        <Color>                 color used to draw selections
claus
parents: 119
diff changeset
    68
      selectionBgColor        <Color>                 color used to draw selections
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    69
120
claus
parents: 119
diff changeset
    70
      selectStyle             <Symbol>                how words are selected
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    71
120
claus
parents: 119
diff changeset
    72
      directoryForFileDialog  <nil|pathName>          directory where save dialog should start
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    73
120
claus
parents: 119
diff changeset
    74
      contentsWasSaved        <Boolean>               set to true, whenever saved in a file
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    75
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    76
      externalEncoding        <Symbol|nil>            external encoding, used when text is saved to
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    77
                                                      a file. Usually something like
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    78
                                                      #jis7, #euc, #sjis etc.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    79
                                                      (currently only passed down from the
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    80
                                                       fileBrowser)
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    81
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    82
    [class variables:]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    83
        ST80Selections        <Boolean>               enables ST80 style doubleclick behavior
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    84
                                                      (right after opening parenthesis, right before
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    85
                                                       closing parenthesis, at begin of a line
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    86
                                                       at begin of text)
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    87
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    88
    [StyleSheet parameters:]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    89
120
claus
parents: 119
diff changeset
    90
      textViewBackground                 defaults to viewBackground
claus
parents: 119
diff changeset
    91
      textSelectionForegroundColor       defaults to textBackgroundColor
claus
parents: 119
diff changeset
    92
      textSelectionBackgroundColor       defaults to textForegroundColor
claus
parents: 119
diff changeset
    93
      textViewFont                       defaults to textFont
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    94
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    95
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    96
    [author:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    97
        Claus Gittinger
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    98
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    99
    [see also:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   100
        EditTextView CodeView Workspace
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   101
"
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   102
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   103
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   104
examples
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   105
"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   106
    although textViews (and instances of subclasses) are mostly used
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   107
    as components (in the fileBrowser, the browser, the launcher etc.),
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   108
    they may also be opened as a textEditor;
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   109
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   110
    open a (readonly) textView on some information text:
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   111
                                                        [exBegin]
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   112
        TextView 
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   113
            openWith:'read this' 
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   114
            title:'demonstration'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   115
                                                        [exEnd]
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   116
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   117
    the same, but open it modal:
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   118
                                                        [exBegin]
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   119
        TextView 
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   120
            openModalWith:'read this first' 
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   121
            title:'demonstration'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   122
                                                        [exEnd]
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   123
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   124
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   125
    open it modal (but editable) on some text:
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   126
    (must accept before closing)
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   127
    This is somewhat kludgy - when closed, the view has already
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   128
    nilled its link to the model. Therefore, the accept must be
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   129
    done 'manually' below.
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   130
    However, usually an applicationModel is installed as the
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   131
    editor-topViews application. This would get a closeRequest,
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   132
    where it could handle things.
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   133
                                                        [exBegin]
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   134
        |m textView|
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   135
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   136
        m := 'read this first' asValue.
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   137
        textView := EditTextView openModalOnModel:m.
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   138
        textView modified ifTrue:[
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   139
            (self confirm:'text was not accepted - do it now ?')
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   140
            ifTrue:[
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   141
                m value:textView contents
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   142
            ]
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   143
        ].
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   144
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   145
        Transcript showCR:m value.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   146
                                                        [exEnd]
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   147
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   148
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   149
    open a textEditor on some file:
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   150
                                                        [exBegin]
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   151
        EditTextView openOn:'Makefile'
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   152
                                                        [exEnd]
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   153
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   154
"
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   155
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   156
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   157
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   158
!TextView class methodsFor:'instance creation'!
119
claus
parents: 97
diff changeset
   159
claus
parents: 97
diff changeset
   160
on:aModel aspect:aspect change:change menu:menu initialSelection:initial
claus
parents: 97
diff changeset
   161
    "for ST-80 compatibility"
claus
parents: 97
diff changeset
   162
120
claus
parents: 119
diff changeset
   163
    ^ (self new) 
claus
parents: 119
diff changeset
   164
	on:aModel 
claus
parents: 119
diff changeset
   165
	aspect:aspect
claus
parents: 119
diff changeset
   166
	list:aspect
claus
parents: 119
diff changeset
   167
	change:change 
claus
parents: 119
diff changeset
   168
	menu:menu
claus
parents: 119
diff changeset
   169
	initialSelection:initial
119
claus
parents: 97
diff changeset
   170
! !
claus
parents: 97
diff changeset
   171
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   172
!TextView class methodsFor:'defaults'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   173
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   174
defaultIcon
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   175
    "return the default icon if started as a topView"
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   176
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   177
    <resource: #style (#ICON #ICON_FILE)>
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   178
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   179
    |nm i|
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   180
1146
027884518745 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   181
    i := self classResources at:'ICON' default:nil.
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   182
    i isNil ifTrue:[
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   183
        nm := ClassResources at:'ICON_FILE' default:'Editor.xbm'.
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   184
        i := Image fromFile:nm resolution:100.
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   185
        i isNil ifTrue:[
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   186
            i := Image fromFile:('bitmaps/' , nm) resolution:100.
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   187
        ]
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   188
    ].
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   189
    i notNil ifTrue:[
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   190
        i := i on:Display
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   191
    ].
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   192
    ^ i
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   193
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   194
    "Modified: 18.4.1997 / 15:18:06 / cg"
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   195
!
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   196
910
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   197
defaultMenuMessage
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   198
    "This message is the default yo be sent to the menuHolder to get a menu"
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   199
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   200
    ^ #editMenu
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   201
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   202
    "Created: 3.1.1997 / 01:52:21 / stefan"
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   203
!
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   204
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   205
updateStyleCache
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   206
    "extract values from the styleSheet and cache them in class variables"
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   207
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   208
    <resource: #style (#'textView.background'
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   209
                       #'textSelection.foregroundColor' #'textSelection.backgroundColor'
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   210
                       #'textView.font' #textWordSelectCatchesBlanks
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   211
                       #st80Selections)>
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   212
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   213
    DefaultViewBackground := StyleSheet colorAt:'textView.background' default:White.
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   214
    DefaultSelectionForegroundColor := StyleSheet colorAt:'textSelection.foregroundColor'.
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   215
    DefaultSelectionBackgroundColor := StyleSheet colorAt:'textSelection.backgroundColor'.
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   216
    DefaultFont := StyleSheet fontAt:'textView.font'.
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
   217
    MatchDelayTime := 0.6.
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
   218
    WordSelectCatchesBlanks := StyleSheet at:'textWordSelectCatchesBlanks' default:false.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   219
    ST80Selections := StyleSheet at:'TextView.st80Selections' default:false.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   220
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   221
    "Modified: 20.10.1997 / 14:05:53 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   222
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   223
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   224
!TextView class methodsFor:'startup'!
121
claus
parents: 120
diff changeset
   225
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   226
open
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   227
    "start an empty TextView"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   228
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   229
    ^ self openWith:nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   230
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   231
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   232
openModalOnModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   233
    "start a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   234
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   235
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   236
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   237
    textView := self setupForModel:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   238
    textView topView openModal.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   239
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   240
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   241
    "Created: 14.2.1997 / 15:24:12 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   242
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   243
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   244
openModalWith:aString
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   245
    "start a textView with aString as initial contents"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   246
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   247
    ^ self openModalWith:aString title:nil 
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   248
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   249
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   250
     TextView openModalWith:'some text'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   251
     EditTextView openModalWith:'some text'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   252
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   253
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   254
    "Created: 14.2.1997 / 15:19:04 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   255
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   256
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   257
openModalWith:aString title:aTitle
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   258
    "start a textView with aString as initial contents. Return the textView."
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   259
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   260
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   261
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   262
    textView := self setupWith:aString title:aTitle.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   263
    textView topView openModal.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   264
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   265
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   266
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   267
     TextView openModalWith:'some text' title:'testing'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   268
     EditTextView openModalWith:'some text' title:'testing'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   269
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   270
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   271
    "Modified: 9.9.1996 / 19:32:29 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   272
    "Created: 14.2.1997 / 15:19:18 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   273
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   274
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   275
openOn:aFileName
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   276
    "start a textView on a file; return the textView"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   277
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   278
    |textView|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   279
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   280
    textView := self setupForFile:aFileName.
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   281
    textView topView open.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   282
    ^ textView
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   283
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   284
    "
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   285
     TextView openOn:'../../doc/overview.doc'
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   286
     EditTextView openOn:'../../doc/overview.doc'
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   287
    "
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   288
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   289
    "Modified: 14.2.1997 / 15:21:51 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   290
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   291
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   292
openOnModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   293
    "start a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   294
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   295
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   296
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   297
    textView := self setupForModel:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   298
    textView topView open.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   299
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   300
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   301
    "Created: 14.2.1997 / 15:23:36 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   302
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   303
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   304
openWith:aStringOrStringCollection
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   305
    "start a textView with aStringOrStringCollection as initial contents"
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   306
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   307
    ^ self openWith:aStringOrStringCollection title:nil 
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   308
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   309
    "
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   310
     TextView openWith:'some text'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   311
     EditTextView openWith:'some text'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   312
    "
119
claus
parents: 97
diff changeset
   313
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   314
    "Created: 10.12.1995 / 17:41:32 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   315
    "Modified: 5.3.1997 / 15:37:19 / cg"
126
claus
parents: 121
diff changeset
   316
!
claus
parents: 121
diff changeset
   317
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   318
openWith:aStringOrStringCollection title:aTitle
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   319
    "start a textView with aStringOrStringCollection as initial contents. Return the textView."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   320
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   321
    |textView|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   322
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   323
    textView := self setupWith:aStringOrStringCollection title:aTitle.
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   324
    textView topView open.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   325
    ^ textView
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   326
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   327
    "
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   328
     TextView openWith:'some text' title:'testing'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   329
     EditTextView openWith:'some text' title:'testing'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   330
    "
126
claus
parents: 121
diff changeset
   331
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   332
    "Created: 10.12.1995 / 17:40:02 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   333
    "Modified: 5.3.1997 / 15:37:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   334
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   335
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   336
setupEmpty
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   337
    "create a textview in a topview, with horizontal and
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   338
     vertical scrollbars - a helper for #startWith: and #startOn:"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   339
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   340
    |top frame label|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   341
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   342
    label := 'unnamed'.
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   343
    top := StandardSystemView label:label icon:self defaultIcon.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   344
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   345
    frame := HVScrollableView 
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   346
                for:self 
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   347
                miniScrollerH:true miniScrollerV:false
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   348
                in:top.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   349
    frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   350
    ^ frame scrolledView
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   351
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   352
    "Modified: 23.5.1965 / 14:12:32 / cg"
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   353
!
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   354
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   355
setupForFile:aFileName
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   356
    "setup a textView on a file; return the textView"
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   357
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   358
    |top textView f|
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   359
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   360
    textView := self setupEmpty.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   361
    top := textView topView.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   362
    aFileName notNil ifTrue:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   363
	f := aFileName asFilename.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   364
        top label:(f baseName).
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   365
        textView contents:(f contents).
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   366
    ].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   367
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   368
    ^ textView
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   369
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   370
    "Created: 14.2.1997 / 15:21:43 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   371
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   372
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   373
setupForModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   374
    "setup a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   375
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   376
    |top textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   377
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   378
    textView := self setupEmpty.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   379
    textView model:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   380
    top := textView topView.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   381
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   382
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   383
    "Created: 14.2.1997 / 15:22:42 / cg"
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   384
!
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   385
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   386
setupWith:aStringOrStringCollection title:aTitle
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   387
    "setup a textView with aStringOrStringCollection as initial contents in a topView"
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   388
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   389
    |top textView|
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   390
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   391
    textView := self setupEmpty.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   392
    top := textView topView.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   393
    aTitle notNil ifTrue:[top label:aTitle].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   394
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   395
    aStringOrStringCollection notNil ifTrue:[
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   396
        textView contents:aStringOrStringCollection
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   397
    ].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   398
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   399
    ^ textView
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   400
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   401
    "Created: 9.9.1996 / 19:31:22 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   402
    "Modified: 5.3.1997 / 15:37:37 / cg"
119
claus
parents: 97
diff changeset
   403
! !
claus
parents: 97
diff changeset
   404
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   405
!TextView methodsFor:'accessing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   406
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   407
characterPositionOfSelection
1303
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   408
    "return the character index of the first character in the selection.
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   409
     Returns 0 if there is no selection."
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   410
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   411
    selectionStartLine isNil ifTrue:[^ 0].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   412
    ^ self characterPositionOfLine:selectionStartLine
1303
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   413
                               col:selectionStartCol
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   414
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   415
    "Modified: 14.8.1997 / 16:35:37 / cg"
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   416
!
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   417
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   418
characterPositionOfSelectionEnd
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   419
    "return the character index of the last character in the selection.
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   420
     Returns 0 if there is no selection."
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   421
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   422
    selectionStartLine isNil ifTrue:[^ 0].
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   423
    ^ self characterPositionOfLine:selectionEndLine
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   424
                               col:selectionEndCol
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   425
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   426
    "Created: 14.8.1997 / 16:35:24 / cg"
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   427
    "Modified: 14.8.1997 / 16:35:45 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   428
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   429
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   430
contentsWasSaved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   431
    "return true, if the contents was saved (by a save action),
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   432
     false if not (or was modified again after the last save)."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   433
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   434
    ^ contentsWasSaved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   435
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   436
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   437
defaultFileNameForFileDialog:aBaseName
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   438
    "define the default fileName to use for the save-box"
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   439
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   440
    defaultFileNameForFileDialog := aBaseName
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   441
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   442
    "Created: 13.2.1997 / 18:29:53 / cg"
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   443
!
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   444
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   445
directoryForFileDialog:aDirectory
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   446
    "define the default directory to use for save-box"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   447
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   448
    directoryForFileDialog := aDirectory
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   449
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   450
    "Modified: 13.2.1997 / 18:30:01 / cg"
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   451
!
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   452
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   453
externalEncoding:encodingSymOrNil
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   454
    "define how the contents should be encoded when saved
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   455
     via the 'save / save as' dialog.
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   456
     This is (currently) only passed down from the fileBrowser,
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   457
     and required when japanese/chines/korean text is edited.
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   458
     (encoding is one of #euc, #sjis, #jis7, #gb, #big5 or #ksc)"
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   459
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   460
    externalEncoding := encodingSymOrNil
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   461
! !
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   462
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   463
!TextView methodsFor:'accessing-contents'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   464
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   465
fromFile:aFileName
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   466
    "take contents from a named file"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   467
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   468
    |f|
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   469
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   470
    f := aFileName asFilename.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   471
    self directoryForFileDialog:(f directoryName).
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
   472
    self contents:(f contents)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   473
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   474
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   475
list:something
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   476
    "set the displayed contents (a collection of strings)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   477
     with redraw.
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   478
     Redefined since changing the contents implies deselect"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   479
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   480
    self unselect.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   481
    super list:something
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   482
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   483
    "Modified: 29.4.1996 / 12:13:24 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   484
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   485
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   486
setList:something
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   487
    "set the displayed contents (a collection of strings)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   488
     without redraw.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   489
     Redefined since changing contents implies deselect"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   490
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   491
    self unselect.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   492
    super setList:something
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   493
!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   494
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   495
wordAtLine:selectLine col:selectCol do:aFiveArgBlock
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   496
    "find word boundaries, evaluate the block argument with those.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   497
     A helper for nextWord and selectWord functions."
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   498
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   499
    |beginCol endCol endLine thisCharacter flag|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   500
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   501
    flag := #word.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   502
    beginCol := selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   503
    endCol := selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   504
    endLine := selectLine.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   505
    thisCharacter := self characterAtLine:selectLine col:beginCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   506
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   507
    beginCol := self findBeginOfWordAtLine:selectLine col:selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   508
    endCol := self findEndOfWordAtLine:selectLine col:selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   509
    endCol == 0 ifTrue:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   510
        endLine := selectLine + 1
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   511
    ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   512
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   513
    "is the initial acharacter within a word ?"
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   514
    (wordCheck value:thisCharacter) ifTrue:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   515
        "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   516
         try to catch a blank ...
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   517
        "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   518
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   519
        WordSelectCatchesBlanks ifTrue:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   520
            ((beginCol == 1)
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   521
            or:[(self characterAtLine:selectLine col:(beginCol - 1))
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   522
                 ~~ Character space]) ifTrue:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   523
                ((self characterAtLine:selectLine col:(endCol + 1))
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   524
                  == Character space) ifTrue:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   525
                    endCol := endCol + 1.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   526
                    flag := #wordRight
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   527
                ]
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   528
            ] ifFalse:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   529
                beginCol := beginCol - 1.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   530
                flag := #wordLeft
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   531
            ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   532
        ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   533
    ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   534
    aFiveArgBlock value:selectLine 
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   535
                  value:beginCol 
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   536
                  value:endLine 
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   537
                  value:endCol
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   538
                  value:flag
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   539
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   540
    "Modified: 18.3.1996 / 17:31:04 / cg"
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   541
! !
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   542
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   543
!TextView methodsFor:'accessing-look'!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   544
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   545
selectionForegroundColor:color1 backgroundColor:color2
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   546
    "set both the selection-foreground and cursor background colors.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   547
     The default is defined by the styleSheet; 
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   548
     typically black-on-green for color displays and white-on-black for b&w displays."
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   549
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   550
    selectionFgColor := color1 on:device.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   551
    selectionBgColor := color2 on:device.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   552
    shown ifTrue:[
712
9d6da14413a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   553
        self hasSelection ifTrue:[
722
3f297a438fec use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   554
            self invalidate
712
9d6da14413a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   555
        ]
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   556
    ]
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   557
722
3f297a438fec use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   558
    "Modified: 29.5.1996 / 16:22:15 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   559
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   560
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   561
!TextView methodsFor:'accessing-mvc'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   562
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   563
on:aModel aspect:aspectSym list:listSym change:changeSym menu:menuSym initialSelection:initial
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   564
    "set all of model, aspect, listMessage, changeSymbol, menySymbol
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   565
     and selection. Added for ST-80 compatibility"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   566
906
a8b9b481ce70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   567
    aspectSym notNil ifTrue:[aspectMsg := aspectSym. 
a8b9b481ce70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   568
                             listMsg isNil ifTrue:[listMsg := aspectSym]].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   569
    changeSym notNil ifTrue:[changeMsg := changeSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   570
    listSym notNil ifTrue:[listMsg := listSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   571
    menuSym notNil ifTrue:[menuMsg := menuSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   572
"/    initial notNil ifTrue:[initialSelectionMsg := initial].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   573
    self model:aModel.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   574
824
f62922fcfa5d Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   575
    "Modified: 15.8.1996 / 12:52:54 / stefan"
906
a8b9b481ce70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   576
    "Modified: 2.1.1997 / 16:11:28 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   577
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   578
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   579
!TextView methodsFor:'event processing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   580
53
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
   581
buttonMotion:buttonMask x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   582
    "mouse-move while button was pressed - handle selection changes"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   583
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   584
    |movedVisibleLine movedLine movedCol 
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   585
     movedUp 
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   586
     oldStartLine oldEndLine oldStartCol oldEndCol|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   587
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   588
    clickLine isNil ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   589
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   590
    "is it the select or 1-button ?"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   591
    (device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   592
	(device buttonMotionMask:buttonMask includesButton:1) ifFalse:[
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   593
	    ^ self
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   594
	].
53
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
   595
    ].
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
   596
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   597
    "if moved outside of view, start autoscroll"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   598
    (y < 0) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   599
	self compressMotionEvents:false.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   600
	self startAutoScrollUp:y.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   601
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   602
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   603
    (y > height) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   604
	self compressMotionEvents:false.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   605
	self startAutoScrollDown:(y - height).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   606
	^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   607
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   608
    ((x < 0) and:[leftOffset ~~ 0]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   609
	self compressMotionEvents:false.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   610
	self startAutoScrollLeft:x.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   611
	^ self
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   612
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   613
    (x > width) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   614
	self compressMotionEvents:false.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   615
	self startAutoScrollRight:(x - width).
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   616
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   617
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   618
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   619
    "move inside - stop autoscroll if any"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   620
    autoScrollBlock notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   621
	self stopScrollSelect
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   622
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   623
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   624
    movedVisibleLine := self visibleLineOfY:y.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   625
    movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   626
    (x < leftMargin) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   627
	movedCol := 0
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   628
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   629
	movedCol := self colOfX:x inVisibleLine:movedVisibleLine
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   630
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   631
    ((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   632
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   633
    selectionStartLine isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   634
	selectionStartLine := clickLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   635
	selectionStartCol := clickCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   636
	selectionEndLine := selectionStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   637
	selectionEndCol := selectionStartCol
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   638
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   639
    oldStartLine := selectionStartLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   640
    oldEndLine := selectionEndLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   641
    oldStartCol := selectionStartCol.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   642
    oldEndCol := selectionEndCol.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   643
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   644
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   645
    "find out if we are before or after initial click"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   646
    movedUp := false.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   647
    (movedLine < clickStartLine) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   648
	movedUp := true
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   649
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   650
	(movedLine == clickStartLine) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   651
	    (movedCol < clickStartCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   652
		movedUp := true
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   653
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   654
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   655
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   656
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   657
    movedUp ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   658
	"change selectionStart"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   659
	selectionStartCol := movedCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   660
	selectionStartLine := movedLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   661
	selectionEndCol := clickStartCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   662
	selectionEndLine := clickStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   663
	selectStyle notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   664
	    selectionEndCol := wordEndCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   665
	    selectionEndLine := wordEndLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   666
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   667
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   668
	"change selectionEnd"
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   669
	selectionEndCol := movedCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   670
	selectionEndLine := movedLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   671
	selectionStartCol := clickStartCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   672
	selectionStartLine := clickStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   673
	selectStyle notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   674
	    selectionStartCol := wordStartCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   675
	    selectionStartLine := wordStartLine.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   676
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   677
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   678
164
Claus Gittinger <cg@exept.de>
parents: 132
diff changeset
   679
    selectionStartLine isNil ifTrue:[^ self].
Claus Gittinger <cg@exept.de>
parents: 132
diff changeset
   680
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   681
    (selectionStartCol == 0) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   682
	selectionStartCol := 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   683
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   684
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   685
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   686
     if in word-select, just catch the rest of the word
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   687
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   688
    (selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   689
	movedUp ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   690
	    selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   691
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   692
	    selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   693
	    selectionEndCol == 0 ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   694
		selectionEndLine := selectionEndLine + 1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   695
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   696
	].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   697
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   698
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   699
    selectStyle == #line ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   700
	movedUp ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   701
	    selectionStartCol := 1.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   702
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   703
	    selectionEndCol := 0.
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   704
	    selectionEndLine := selectionEndLine + 1
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   705
	]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   706
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   707
209
7a6db7fac566 dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   708
    self validateNewSelection.
7a6db7fac566 dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   709
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   710
    (oldStartLine == selectionStartLine) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   711
	(oldStartCol ~~ selectionStartCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   712
	    self redrawLine:oldStartLine 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   713
		       from:((selectionStartCol min:oldStartCol) max:1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   714
			 to:((selectionStartCol max:oldStartCol) max:1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   715
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   716
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   717
	self redrawFromLine:(oldStartLine min:selectionStartLine)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   718
			 to:(oldStartLine max:selectionStartLine)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   719
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   720
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   721
    (oldEndLine == selectionEndLine) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   722
	(oldEndCol ~~ selectionEndCol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   723
	    self redrawLine:oldEndLine 
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   724
		       from:((selectionEndCol min:oldEndCol) max:1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   725
			 to:((selectionEndCol max:oldEndCol) max:1)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   726
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   727
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   728
	self redrawFromLine:(oldEndLine min:selectionEndLine)
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   729
			 to:(oldEndLine max:selectionEndLine)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   730
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   731
    clickLine := movedLine.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   732
    clickCol := movedCol
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   733
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   734
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   735
buttonMultiPress:button x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   736
    "multi-mouse-click - select word under pointer"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   737
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   738
    ((button == 1) or:[button == #select]) ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   739
        clickCount notNil ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   740
            clickCount := clickCount + 1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   741
            (clickCount == 2) ifTrue:[
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   742
                self doubleClickX:x y:y
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   743
            ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   744
                (clickCount == 3) ifTrue:[
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   745
                    self tripleClickX:x y:y
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   746
                ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   747
                    (clickCount == 4) ifTrue:[
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   748
                        self quadClickX:x y:y
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   749
                    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   750
                ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   751
            ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   752
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   753
    ] ifFalse:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   754
        super buttonMultiPress:button x:x y:y
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   755
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   756
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   757
    "Modified: 11.9.1997 / 04:15:35 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   758
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   759
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   760
buttonPress:button x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   761
    "mouse-click - prepare for selection change"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   762
1308
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   763
    |sensor clickVisibleLine|
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   764
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   765
    sensor := self sensor.
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   766
    (sensor notNil and:[ sensor shiftDown]) ifTrue:[
813
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   767
        "mouse-click with shift - adding to selection"
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   768
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   769
        "very simple - just simulate a move"
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   770
        ^ self buttonMotion:(device button1MotionMask) x:x y:y
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   771
    ].
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   772
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   773
    ((button == 1) or:[button == #select]) ifTrue:[
813
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   774
        clickVisibleLine := self visibleLineOfY:y.
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   775
        clickCol := self colOfX:x inVisibleLine:clickVisibleLine.
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   776
        clickLine := self visibleLineToAbsoluteLine:clickVisibleLine.
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   777
        clickStartLine := clickLine.
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   778
        clickStartCol := clickCol.
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   779
        self unselect.
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   780
        clickCount := 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   781
    ] ifFalse:[
813
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   782
        super buttonPress:button x:x y:y
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   783
    ]
813
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   784
1308
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   785
    "Modified: 19.8.1997 / 17:01:15 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   786
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   787
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   788
buttonRelease:button x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   789
    "mouse- button release - turn off autoScroll if any"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   790
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   791
    ((button == 1) or:[button == #select]) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   792
	autoScrollBlock notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   793
	    self stopScrollSelect
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   794
	].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   795
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   796
	super buttonRelease:button x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   797
    ]
824
f62922fcfa5d Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   798
!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   799
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   800
doubleClickX:x y:y
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   801
    "double-click - select word under pointer"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   802
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   803
    |sel ch matchCol scanCol fwdScan|
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   804
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   805
    ST80Selections == true ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   806
        "/ st80 selects:
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   807
        "/   if clicked right after a parenthesis -> select to matching parenthesis
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   808
        "/   if clicked at beginning of the line  -> select that line
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   809
        "/   if clicked at the top of the text    -> select all
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   810
        "/
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   811
        clickCol == 1 ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   812
            clickLine == 1 ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   813
                self selectAll.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   814
                ^ self.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   815
            ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   816
            self selectLineAtY:y.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   817
            selectStyle := #line.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   818
            ^ self
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   819
        ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   820
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   821
        matchCol := nil.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   822
        "/ see what is to the left of that character ...
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   823
        clickCol > 1 ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   824
            ch := self characterAtLine:clickLine col:clickCol-1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   825
            ('([{<' includes:ch) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   826
                matchCol := clickCol - 1
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   827
            ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   828
                ('"' includes:ch) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   829
                    scanCol := clickCol - 1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   830
                    fwdScan := true
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   831
                ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   832
            ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   833
        ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   834
        clickCol < (self listAt:clickLine) size ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   835
            ch := self characterAtLine:clickLine col:clickCol+1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   836
            (')]}>' includes:ch) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   837
                matchCol := clickCol + 1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   838
            ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   839
                ('"' includes:ch) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   840
                    scanCol := clickCol + 1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   841
                    fwdScan := false
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   842
                ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   843
            ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   844
        ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   845
        matchCol notNil ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   846
            self searchForMatchingParenthesisFromLine:clickLine col:matchCol
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   847
                   ifFound:[:line :col | 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   848
                            self selectFromLine:clickLine col:matchCol
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   849
                                 toLine:line col:col.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   850
                            ^ self
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   851
                           ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   852
                   ifNotFound:[self showNotFound]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   853
                      onError:[self beep].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   854
            ^ self
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   855
        ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   856
        scanCol notNil ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   857
            "/ if its an EOL comment, do it differently
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   858
            ch := self characterAtLine:clickLine col:clickCol.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   859
            ch == $/ ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   860
                self selectFromLine:clickLine col:clickCol+1 toLine:clickLine+1 col:0.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   861
                ^ self
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   862
            ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   863
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   864
            self scanFor:$" fromLine:clickLine col:scanCol forward:fwdScan
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   865
                 ifFound:[:line :col |
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   866
                            fwdScan ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   867
                                self selectFromLine:clickLine col:scanCol+1
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   868
                                     toLine:line col:col-1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   869
                            ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   870
                                self selectFromLine:clickLine col:scanCol-1
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   871
                                     toLine:line col:col+1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   872
                            ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   873
                            ^ self
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   874
                           ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   875
                 ifNotFound:[self showNotFound].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   876
            ^ self
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   877
        ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   878
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   879
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   880
    self selectWordAtX:x y:y.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   881
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   882
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   883
     special - if clicked on a parenthesis, select to matching
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   884
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   885
    ((sel := self selection) size == 1 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   886
    and:[(sel := sel at:1) size == 1]) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   887
        ch := sel at:1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   888
        ('()[]{}<>' includes:ch) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   889
            self searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   890
                  ifFound:[:line :col | 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   891
                              |prevLine prevCol moveBack pos1|
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   892
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   893
                              prevLine := firstLineShown.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   894
                              prevCol := leftOffset.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   895
                              self selectFromLine:selectionStartLine col:selectionStartCol
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   896
                                           toLine:line col:col.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   897
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   898
                              self sensor ctrlDown ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   899
                                  "/ undo scroll operation ...
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   900
                                  self withCursor:Cursor eye do:[  
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   901
                                      moveBack := false.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   902
                                      (')]}>' includes:ch) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   903
                                           (firstLineShown ~~ prevLine or:[prevCol ~~ leftOffset]) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   904
                                               moveBack := true
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   905
                                           ] 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   906
                                      ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   907
                                           selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   908
                                               self makeLineVisible:selectionEndLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   909
                                               moveBack := true
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   910
                                           ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   911
                                      ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   912
                                      moveBack ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   913
                                           pos1 := x@y. 
1332
0794ee877118 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1329
diff changeset
   914
                                           self invalidateRepairNow:true.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   915
                                           Delay waitForSeconds:MatchDelayTime. 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   916
                                            
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   917
                                           [self sensor hasUserEventFor:self] whileFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   918
                                                Delay waitForSeconds:MatchDelayTime / 2.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   919
                                           ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   920
                                           self scrollToLine:prevLine; scrollToCol:prevCol.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   921
                                      ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   922
                                  ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   923
                              ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   924
                          ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   925
               ifNotFound:[self showNotFound]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   926
                  onError:[self beep].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   927
            selectStyle := nil
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   928
        ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   929
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   930
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   931
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   932
     remember words position in case of a drag following
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   933
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   934
    wordStartLine := selectionStartLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   935
    wordEndLine := selectionEndLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   936
    selectStyle == #wordLeft ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   937
        wordStartCol := selectionStartCol + 1
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   938
    ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   939
        wordStartCol := selectionStartCol.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   940
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   941
    selectStyle == #wordRight ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   942
        wordEndCol := selectionEndCol - 1
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   943
    ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   944
        wordEndCol := selectionEndCol
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   945
    ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   946
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   947
    "Created: 11.9.1997 / 04:12:55 / cg"
1332
0794ee877118 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1329
diff changeset
   948
    "Modified: 19.9.1997 / 06:43:10 / cg"
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   949
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   950
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   951
keyPress:key x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   952
    "handle some keyboard input (there is not much to be done here)"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   953
447
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   954
    <resource: #keyboard (#Find #Copy #FindNext #FindPrev 
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 916
diff changeset
   955
                          #GotoLine #SelectAll #SaveAs #Print
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 916
diff changeset
   956
                          #'F*' #'f*' )>
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   957
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   958
    (key == #Find) ifTrue:[self search. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   959
    (key == #Copy) ifTrue:[self copySelection. ^self].
447
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   960
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   961
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   962
    (key == #FindNext) ifTrue:[self searchFwd. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   963
    (key == #FindPrev) ifTrue:[self searchBwd. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   964
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   965
    (key == #SelectAll) ifTrue:[self selectAll. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   966
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   967
    (key == #SaveAs)    ifTrue:[self save.    ^self].
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   968
    (key == #Print)     ifTrue:[self doPrint. ^self].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   969
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   970
    "
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   971
     shift-Fn defines a key-sequence 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   972
     Fn       pastes that sequence
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   973
     cmd-Fn   performs a 'doIt' on the sequence (Workspaces only)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   974
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   975
     (see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   976
    "
1193
811135bbd017 Do not crash when typing simple keys.
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   977
    (key size > 1 and:[(key at:1) asLowercase == $f]) ifTrue:[
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   978
        (('[fF][0-9]' match:key)
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   979
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   980
            self sensor shiftDown ifTrue:[
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   981
                (Smalltalk at:#FunctionKeySequences) isNil ifTrue:[
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   982
                    Smalltalk at:#FunctionKeySequences put:Dictionary new
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   983
                ].
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   984
                (Smalltalk at:#FunctionKeySequences) at:key put:(self selection)
326
f04c328526c4 use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   985
            ].
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   986
            ^ self
326
f04c328526c4 use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   987
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   988
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   989
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   990
    super keyPress:key x:x y:y
326
f04c328526c4 use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   991
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
   992
    "Modified: 2.4.1997 / 16:48:26 / cg"
1193
811135bbd017 Do not crash when typing simple keys.
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   993
    "Modified: 18.4.1997 / 12:12:27 / stefan"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   994
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   995
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   996
mapped 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   997
    super mapped.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   998
    selectionFgColor := selectionFgColor on:device.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   999
    selectionBgColor := selectionBgColor on:device.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1000
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1001
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1002
quadClickX:x y:y
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1003
    "qaudrupleClick-click - select all"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1004
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1005
    self selectAll
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1006
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1007
    "Created: 11.9.1997 / 04:15:24 / cg"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1008
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1009
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1010
tripleClickX:x y:y
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1011
    "triple-click - select line under pointer"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1012
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1013
    self selectLineAtY:y.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1014
    selectStyle := #line
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1015
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1016
    "Created: 11.9.1997 / 04:13:37 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1017
! !
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1018
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1019
!TextView methodsFor:'initialize & release'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1020
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1021
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1022
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1023
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1024
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1025
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1026
    selectionFgColor notNil ifTrue:[selectionFgColor := selectionFgColor on:device].
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1027
    selectionBgColor notNil ifTrue:[selectionBgColor := selectionBgColor on:device].
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1028
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1029
    "Created: 14.1.1997 / 00:14:33 / cg"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1030
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1031
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1032
initStyle
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1033
    "setup viewStyle specifics"
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1034
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1035
    super initStyle.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1036
392
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1037
"/    DefaultFont notNil ifTrue:[font := DefaultFont on:device].
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1038
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1039
    viewBackground := DefaultViewBackground.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1040
    selectionFgColor := DefaultSelectionForegroundColor.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1041
    selectionFgColor isNil ifTrue:[selectionFgColor := bgColor].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1042
    selectionBgColor := DefaultSelectionBackgroundColor.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1043
    selectionBgColor isNil ifTrue:[
708
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1044
        device hasColors ifTrue:[
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1045
            DefaultSelectionForegroundColor isNil ifTrue:[
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1046
                selectionFgColor := fgColor
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1047
            ].
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1048
            selectionBgColor := Color green
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1049
        ] ifFalse:[
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1050
            device hasGrayscales ifTrue:[
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1051
                DefaultSelectionForegroundColor isNil ifTrue:[
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1052
                    selectionFgColor := fgColor
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1053
                ].
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1054
                selectionBgColor := Color grey
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1055
            ] ifFalse:[
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1056
                selectionBgColor := fgColor
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1057
            ]
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1058
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1059
    ].
708
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1060
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1061
    "Modified: 22.1.1997 / 11:57:53 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1062
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1063
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1064
initialize
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1065
    super initialize.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1066
    contentsWasSaved := false.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1067
911
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1068
    "I handle menus myself"
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1069
    menuHolder := menuPerformer := self.
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1070
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1071
    "Modified: 3.1.1997 / 02:14:01 / stefan"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1072
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1073
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1074
!TextView methodsFor:'menu actions'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1075
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1076
appendTo:fileName
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1077
    "append contents to a file named fileName"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1078
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1079
    |aStream msg|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1080
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1081
    aStream := FileStream appendingOldFileNamed:fileName.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1082
    aStream isNil ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1083
	msg := resources string:'cannot append to file %1 !!' with:fileName.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1084
	self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1085
    ] ifFalse:[
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1086
	self 
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1087
	    fileOutContentsOn:aStream 
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1088
	    compressTabs:true 
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1089
	    encoding:externalEncoding.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1090
	aStream close.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1091
	contentsWasSaved := true
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1092
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1093
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1094
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1095
changeFont
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1096
    "pop up a fontPanel to change font"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1097
411
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1098
    |newFont|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1099
411
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1100
    newFont := FontPanel fontFromUserInitial:font.
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1101
    newFont notNil ifTrue:[
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1102
        self font:newFont.
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1103
    ]
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1104
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1105
    "Modified: 27.2.1996 / 00:53:51 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1106
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1107
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1108
copySelection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1109
    "copy contents into smalltalk copybuffer"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1110
863
ed4282df00a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 860
diff changeset
  1111
    |text|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1112
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1113
    text := self selection.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1114
    text notNil ifTrue:[
649
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1115
        self unselect.
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1116
863
ed4282df00a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 860
diff changeset
  1117
	"/ forget any emphasis ...
ed4282df00a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 860
diff changeset
  1118
        text := text collect:[:l | l isNil ifTrue:[l] ifFalse:[l string]].
649
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1119
        self setTextSelection:text.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1120
    ]
649
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1121
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1122
    "Modified: 17.5.1996 / 08:57:54 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1123
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1124
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1125
defaultForGotoLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1126
    "return a default value to show in the gotoLine box"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1127
447
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1128
    ^ selectionStartLine
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1129
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1130
    "Modified: 1.3.1996 / 18:44:36 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1131
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1132
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1133
doPrint
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1134
    "print the contents on the printer"
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1135
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1136
    |printStream|
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1137
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1138
    list isNil ifTrue:[^ self].
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1139
829
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1140
    self withWaitCursorDo:[
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1141
        printStream := Printer new.
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1142
        printStream notNil ifTrue:[
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1143
            Printer writeErrorSignal handle:[:ex |
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1144
                self warn:('error while printing:\\' 
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1145
                            , ex errorString 
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1146
                            , '\\(printing with: ' , (Printer printCommand) , ')') withCRs
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1147
            ] do:[
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1148
                self fileOutContentsOn:printStream.
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1149
            ].
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1150
            printStream close
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1151
        ]
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1152
    ].
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1153
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1154
    "Created: 6.5.1996 / 16:11:26 / cg"
829
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1155
    "Modified: 5.9.1996 / 19:18:30 / cg"
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1156
!
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1157
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1158
editMenu
1109
83d8c0143ef9 commentary
Claus Gittinger <cg@exept.de>
parents: 1100
diff changeset
  1159
    "return my popUpMenu"
83d8c0143ef9 commentary
Claus Gittinger <cg@exept.de>
parents: 1100
diff changeset
  1160
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1161
    <resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)>
1262
d69149b5be1f resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1162
    <resource: #programMenu>
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1163
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1164
    |labels selectors m|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1165
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1166
    labels := #(
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1167
                        'copy'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1168
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1169
                        'font ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1170
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1171
                        'search ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1172
                        'goto ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1173
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1174
                        'save as ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1175
                        'print'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1176
                ).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1177
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1178
    selectors := #(
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1179
                        copySelection
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1180
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1181
                        changeFont
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1182
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1183
                        search
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1184
                        gotoLine
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1185
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1186
                        save
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1187
                        doPrint
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1188
                  ).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1189
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1190
    m := PopUpMenu
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1191
           labels:(resources array:labels)
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1192
           selectors:selectors
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1193
           accelerators:#(
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1194
                           #Copy
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1195
                           nil
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1196
                           nil
731
c5046b75640f Print accel was wrong
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1197
                           nil
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1198
                           #Find
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1199
                           #GotoLine
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1200
                           nil
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1201
                           #SaveAs
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1202
                           #Print
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1203
                         ).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1204
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1205
    self hasSelection ifFalse:[
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1206
        m disable:#copySelection.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1207
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1208
    ^ m
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1209
1262
d69149b5be1f resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1210
    "Modified: 3.7.1997 / 13:54:09 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1211
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1212
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1213
find
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1214
    "same as search - for VW compatibility"
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1215
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1216
    self search
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1217
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1218
    "Created: 31.7.1997 / 19:13:58 / cg"
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1219
!
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1220
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1221
gotoLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1222
    "show a box to enter lineNumber for positioning"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1223
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1224
    |l lineNumberBox|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1225
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1226
    lineNumberBox :=
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1227
        EnterBox
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1228
           title:(resources string:'line number:')
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1229
           okText:(resources string:'goto')
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1230
           abortText:(resources string:'cancel')
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1231
           action:[:l | |num|
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1232
                       num := Integer readFromString:l onError:nil.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1233
                       num notNil ifTrue:[self gotoLine:num]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1234
                  ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1235
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1236
    l := self defaultForGotoLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1237
    l notNil ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1238
        l := l printString
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1239
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1240
    lineNumberBox initialText:l .
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1241
    lineNumberBox showAtPointer
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1242
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1243
    "Modified: 6.3.1996 / 13:12:27 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1244
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1245
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1246
save
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1247
    "save contents into a file 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1248
     - ask user for filename using a fileSelectionBox."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1249
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1250
    |fileBox|
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1251
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1252
    fileBox := FileSaveBox
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1253
                    title:(resources string:'save contents in:')
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1254
                    okText:(resources string:'save')
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1255
                    abortText:(resources string:'cancel')
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1256
                    action:[:fileName | self saveAs:fileName].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1257
    fileBox appendAction:[:fileName | self appendTo:fileName].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1258
    directoryForFileDialog notNil ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1259
        fileBox directory:directoryForFileDialog
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1260
    ].
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1261
    defaultFileNameForFileDialog notNil ifTrue:[
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1262
        fileBox initialText:defaultFileNameForFileDialog asString
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1263
    ].
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1264
    fileBox showAtPointer.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1265
1188
1ad187181fcb destroy saveBox after use.
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  1266
    directoryForFileDialog := fileBox directory.  "/ remember for next time
1ad187181fcb destroy saveBox after use.
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  1267
1ad187181fcb destroy saveBox after use.
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  1268
    fileBox destroy.
1ad187181fcb destroy saveBox after use.
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  1269
1ad187181fcb destroy saveBox after use.
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
  1270
    "Modified: 16.4.1997 / 20:49:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1271
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1272
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1273
saveAs:fileName
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1274
    "save the contents into a file named fileName"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1275
 
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1276
    self withCursor:Cursor write do:[
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1277
        |aStream msg|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1278
1349
09db5ecfb437 catch file errors when saving
Claus Gittinger <cg@exept.de>
parents: 1337
diff changeset
  1279
        FileStream openErrorSignal catch:[
09db5ecfb437 catch file errors when saving
Claus Gittinger <cg@exept.de>
parents: 1337
diff changeset
  1280
            aStream := FileStream newFileNamed:fileName.
09db5ecfb437 catch file errors when saving
Claus Gittinger <cg@exept.de>
parents: 1337
diff changeset
  1281
        ].
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1282
        aStream isNil ifTrue:[
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1283
            msg := resources string:'cannot write file %1 !!' with:fileName.
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1284
            self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1285
        ] ifFalse:[
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1286
            self
1349
09db5ecfb437 catch file errors when saving
Claus Gittinger <cg@exept.de>
parents: 1337
diff changeset
  1287
                fileOutContentsOn:aStream 
09db5ecfb437 catch file errors when saving
Claus Gittinger <cg@exept.de>
parents: 1337
diff changeset
  1288
                compressTabs:true 
09db5ecfb437 catch file errors when saving
Claus Gittinger <cg@exept.de>
parents: 1337
diff changeset
  1289
                encoding:externalEncoding.
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1290
            aStream close.
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1291
            contentsWasSaved := true
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1292
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1293
    ]
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1294
1349
09db5ecfb437 catch file errors when saving
Claus Gittinger <cg@exept.de>
parents: 1337
diff changeset
  1295
    "Modified: 13.10.1997 / 12:22:39 / cg"
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1296
!
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1297
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1298
search
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1299
    "search for a string - show a box to enter searchpattern 
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1300
     - currently no regular expressions are handled."
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1301
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1302
    "
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1303
     Q: should we preserve the last searchstring between views ?
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1304
    "
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1305
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1306
    |searchBox stringHolder caseHolder b pattern fwd ign|
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1307
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1308
    ign := lastSearchIgnoredCase ? false.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1309
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1310
    searchBox := Dialog new.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1332
diff changeset
  1311
    searchBox label:'string search'.
1329
cf4ff8c407ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
  1312
    (searchBox addTextLabel:(resources at:'searchPattern:')) adjust:#left.
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1313
    searchBox addVerticalSpace.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1314
    searchBox leftIndent:ViewSpacing; rightIndent:ViewSpacing.    
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1315
    searchBox addInputFieldOn:(stringHolder := '' asValue).
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1316
    searchBox addVerticalSpace.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1317
    searchBox addCheckBox:(resources string:'ignore case') on:(caseHolder := ign asValue).
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1318
    searchBox addVerticalSpace.
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1319
"/
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1320
"/ "soon to come: search & replace box ...
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1321
"/
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1322
"/    searchBox addLabel:((resources string:'replace with:').
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1323
"/    searchBox addInputFieldOn:(replacementHolder := '' asValue).
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1324
"/    searchBox addVerticalSpace.
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1325
"/
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1326
    searchBox addAbortButtonLabelled:(resources at:'cancel').
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1327
    b := searchBox addButton:(Button label:(resources at:'prev')).
1337
70043e6a8f08 backward search fixed
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  1328
    b action:[fwd := false. searchBox okPressed].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1329
    b := searchBox addOkButtonLabelled:(resources at:'next').
1337
70043e6a8f08 backward search fixed
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  1330
    b action:[fwd := true. "searchBox okPressed"].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1331
"/    searchBox addButton:(Button label:(resources at:'all'));
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1332
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1333
    lastSearchPattern notNil ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1334
        stringHolder value:lastSearchPattern
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1335
    ].
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1336
    self hasSelection ifTrue:[
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1337
        selectionStartLine == selectionEndLine ifTrue:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1338
            stringHolder value:self selection
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1339
        ]
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1340
    ].
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1341
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1342
    searchBox open.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1343
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1344
    searchBox accepted ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1345
        pattern := stringHolder value.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1346
        pattern := pattern withoutSeparators. "/ is that a good idea ?
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1347
        pattern notEmpty ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1348
            ign := caseHolder value.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1349
            fwd ifFalse:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1350
                self searchBwd:pattern ignoreCase:ign.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1351
            ] ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1352
                self searchFwd:pattern ignoreCase:ign.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1353
            ]
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1354
        ]
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1355
    ].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1356
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1357
"/    searchBox :=
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1358
"/        EnterBox2
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1359
"/           title:(resources at:'searchPattern:')
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1360
"/         okText1:(resources at:'prev')
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1361
"/         okText2:(resources at:'next')
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1362
"/       abortText:(resources at:'cancel')
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1363
"/         action1:[:pattern | pattern notEmpty ifTrue:[self searchBwd:(pattern withoutSeparators)]]
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1364
"/         action2:[:pattern | pattern notEmpty ifTrue:[self searchFwd:(pattern withoutSeparators)]].
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1365
"/
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1366
"/    searchPattern notNil ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1367
"/        searchBox initialText:searchPattern
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1368
"/    ].
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1369
"/    self hasSelection ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1370
"/        selectionStartLine == selectionEndLine ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1371
"/            searchBox initialText:self selection
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1372
"/        ]
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1373
"/    ].
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1374
"/    searchBox showAtPointer
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1375
1337
70043e6a8f08 backward search fixed
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  1376
    "Modified: 5.10.1997 / 02:03:15 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1377
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1378
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1379
!TextView methodsFor:'private'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1380
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1381
fileOutContentsOn:aStream
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1382
    "save contents on a stream, replacing leading spaces by tab-characters."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1383
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1384
    self 
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1385
	fileOutContentsOn:aStream 
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1386
	compressTabs:true
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1387
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1388
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1389
fileOutContentsOn:aStream compressTabs:compressTabs
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1390
    "save contents on a stream. If compressTabs is true,
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1391
     leading spaces will be replaced by tab-characters in the output."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1392
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1393
    self 
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1394
	fileOutContentsOn:aStream 
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1395
	compressTabs:compressTabs 
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1396
	encoding:nil
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1397
!
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1398
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1399
fileOutContentsOn:aStream compressTabs:compressTabs encoding:encodingSymOrNil
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1400
    "save contents on a stream. If compressTabs is true,
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1401
     leading spaces will be replaced by tab-characters in the output."
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1402
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1403
    |startNr nLines string|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1404
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1405
    aStream isFileStream ifTrue:[
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1406
        "on some systems, writing linewise is very slow (via NFS)
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1407
         therefore we convert to a string and write it in big chunks.
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1408
         To avoid creating huge strings, we do it in blocks of 1000 lines,
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1409
         limiting temporary string creation to about 50-80k.
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1410
        "
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1411
        startNr := 1.
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1412
        nLines := list size.
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1413
        [startNr <= nLines] whileTrue:[
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1414
            string := list asStringWithCRsFrom:startNr 
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1415
                                            to:((startNr + 1000) min:nLines)
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1416
                                  compressTabs:compressTabs.
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1417
	    encodingSymOrNil notNil ifTrue:[
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1418
		string := string encodeInto:encodingSymOrNil
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1419
	    ].
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1420
            aStream nextPutAll:string.
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1421
            startNr := startNr + 1000 + 1.
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1422
        ].
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1423
    ] ifFalse:[
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1424
        list do:[:aLine |
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1425
            aLine notNil ifTrue:[
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1426
	        encodingSymOrNil notNil ifTrue:[
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1427
		    aStream nextPutLine:(aLine encodeInto:encodingSymOrNil)
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1428
	        ] ifFalse:[
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1429
                    aStream nextPutLine:aLine.
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  1430
	 	]
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1431
            ].
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1432
        ]
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1433
    ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1434
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  1435
    "Modified: 8.6.1996 / 11:50:46 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1436
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1437
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1438
getFontParameters
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1439
    "get some info of the used font. They are cached since we use them often ..
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1440
     This is redefined here, to use the fonts maxHeight/maxAscent for
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1441
     line separation. This is required, to allow for proper handling of
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1442
     national characters, such as A-dieresis ..."
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1443
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1444
    font := font on:device.
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1445
    includesNonStrings == true ifTrue:[
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1446
        "/ for now, we do not support variable height entries ...
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1447
        fontHeight := list first heightOn:self
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1448
    ] ifFalse:[
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1449
        fontHeight := font maxHeight.
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1450
    ].
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1451
    fontHeight := fontHeight + lineSpacing.
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1452
    fontAscent := font maxAscent.
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1453
    fontWidth := font width.
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1454
    fontIsFixedWidth := font isFixedWidth.
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1455
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1456
    "Modified: 22.5.1996 / 12:02:47 / cg"
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1457
    "Created: 22.5.1996 / 12:18:34 / cg"
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1458
!
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  1459
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1460
scrollSelectDown
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1461
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1462
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1463
    |prevEndLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1464
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1465
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1466
    selectionEndLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1467
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1468
    self scrollDown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1469
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1470
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1471
    prevEndLine := selectionEndLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1472
    selectionEndLine := firstLineShown + nFullLinesShown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1473
    selectionEndCol := 0.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1474
    prevEndLine to:selectionEndLine do:[:lineNr |
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1475
	self redrawLine:lineNr
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1476
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1477
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1478
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1479
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1480
scrollSelectLeft
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1481
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1482
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1483
    |prevStartLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1484
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1485
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1486
    selectionStartLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1487
    selectionStartCol isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1488
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1489
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1490
    prevStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1491
    selectionStartCol := selectionStartCol - 1 max:1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1492
    self scrollLeft.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1493
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1494
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1495
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1496
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1497
scrollSelectRight
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1498
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1499
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1500
    |prevEndCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1501
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1502
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1503
    selectionEndCol isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1504
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1505
    prevEndCol := selectionEndCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1506
    selectionEndCol := selectionEndCol + 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1507
    self scrollRight.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1508
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1509
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1510
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1511
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1512
scrollSelectUp
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1513
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1514
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1515
    |prevStartLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1516
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1517
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1518
    selectionStartLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1519
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1520
    self scrollUp.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1521
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1522
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1523
    prevStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1524
    selectionStartLine := firstLineShown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1525
    selectionStartCol := 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1526
    selectionStartLine to:prevStartLine do:[:lineNr |
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1527
	self redrawLine:lineNr
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1528
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1529
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1530
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1531
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1532
stopScrollSelect
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1533
    "stop auto scroll; deinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1534
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1535
    autoScrollBlock notNil ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1536
	Processor removeTimedBlock:autoScrollBlock.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1537
	self compressMotionEvents:true.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1538
	autoScrollBlock := nil.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1539
	autoScrollDeltaT := nil
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1540
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1541
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1542
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1543
widthForScrollBetween:firstLine and:lastLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1544
    "return the width in pixels for a scroll between firstLine and lastLine"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1545
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1546
    selectionStartLine notNil ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1547
	(lastLine < selectionStartLine) ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1548
	    (firstLine > selectionEndLine) ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1549
		^ width
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1550
	    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1551
	]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1552
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1553
    ^ super widthForScrollBetween:firstLine and:lastLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1554
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1555
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  1556
!TextView methodsFor:'queries'!
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  1557
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  1558
specClass
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  1559
    self class == TextView ifTrue:[^ TextEditorSpec].
1046
10da5b6bd390 specClass query
ca
parents: 1028
diff changeset
  1560
    ^ super specClass
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  1561
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  1562
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  1563
! !
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  1564
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1565
!TextView methodsFor:'redrawing'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1566
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1567
clearMarginOfVisibleLine:visLine with:color
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1568
    "if there is a margin, clear it - a helper for selection drawing"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1569
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1570
    (leftMargin ~~ 0) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1571
        self paint:color.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1572
        self fillRectangleX:margin
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1573
                          y:(self yOfVisibleLine:visLine)
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1574
                      width:leftMargin
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1575
                     height:fontHeight
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1576
    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1577
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1578
    "Created: 6.3.1996 / 14:22:55 / cg"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1579
!
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1580
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1581
redrawFromVisibleLine:startVisLineNr to:endVisLineNr
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1582
    "redraw a visible line range"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1583
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1584
    |startLine endLine specialCare end selVisStart line1 line2|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1585
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1586
    shown ifFalse:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1587
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1588
    end := endVisLineNr.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1589
    (end > nLinesShown) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1590
	end := nLinesShown
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1591
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1592
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1593
    selectionStartLine isNil ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1594
	specialCare := false
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1595
    ] ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1596
	startLine := self visibleLineToAbsoluteLine:startVisLineNr.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1597
	(startLine > selectionEndLine) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1598
	    specialCare := false
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1599
	] ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1600
	    endLine := self visibleLineToAbsoluteLine:end.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1601
	    (endLine < selectionStartLine) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1602
		specialCare := false
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1603
	    ] ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1604
		specialCare := true
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1605
	    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1606
	]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1607
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1608
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1609
    "easy: nothing is selected"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1610
    specialCare ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1611
	super redrawFromVisibleLine:startVisLineNr to:end.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1612
	^ self
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1613
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1614
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1615
    "easy: all is selected"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1616
    ((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1617
	self drawFromVisibleLine:startVisLineNr to:end with:selectionFgColor
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1618
							and:selectionBgColor.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1619
	^ self
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1620
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1621
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1622
    (selectionStartLine >= firstLineShown) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1623
	"draw unselected top part"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1624
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1625
	selVisStart := self listLineToVisibleLine:selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1626
	super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1627
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1628
	"and first partial selected line"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1629
	self redrawVisibleLine:selVisStart.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1630
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1631
	"rest starts after this one"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1632
	line1 := selVisStart + 1
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1633
    ] ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1634
	line1 := 1
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1635
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1636
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1637
    (line1 > end) ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1638
    (line1 < startVisLineNr) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1639
	line1 := startVisLineNr
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1640
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1641
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1642
    "draw middle part of selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1643
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1644
    (selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1645
	line2 := nLinesShown
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1646
    ] ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1647
	line2 := (self listLineToVisibleLine:selectionEndLine) - 1
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1648
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1649
    (line2 > end) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1650
	line2 := end
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1651
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1652
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1653
    self drawFromVisibleLine:line1 to:line2 with:selectionFgColor
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1654
					     and:selectionBgColor.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1655
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1656
    (line2 >= end) ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1657
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1658
    "last line of selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1659
    self redrawVisibleLine:(line2 + 1).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1660
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1661
    ((line2 + 2) <= end) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1662
	super redrawFromVisibleLine:(line2 + 2) to:end
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1663
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1664
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1665
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1666
redrawMarginOfVisibleLine:visLine
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1667
    "draw margin - a helper for selection drawing"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1668
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1669
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1670
    (leftMargin ~~ 0) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1671
    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1672
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1673
    "Created: 6.3.1996 / 14:21:48 / cg"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1674
!
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1675
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1676
redrawVisibleLine:visLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1677
    "redraw visible line lineNr"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1678
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1679
    |len line l|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1680
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1681
    selectionStartLine notNil ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1682
        line := self visibleLineToAbsoluteLine:visLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1683
        (line between:selectionStartLine and:selectionEndLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1684
            (line == selectionStartLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1685
                (line == selectionEndLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1686
                    "its part-of-single-line selection"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1687
                    self clearMarginOfVisibleLine:visLine with:bgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1688
                    (selectionStartCol > 1) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1689
                        super redrawVisibleLine:visLine
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1690
                                           from:1
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1691
                                             to:(selectionStartCol - 1)
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1692
                    ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1693
                    self drawVisibleLine:visLine from:selectionStartCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1694
                                                   to:selectionEndCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1695
                                                 with:selectionFgColor
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1696
                                                  and:selectionBgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1697
                    super redrawVisibleLine:visLine
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1698
                                       from:(selectionEndCol + 1).
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1699
                    ^ self
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1700
                ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1701
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1702
                "its the first line of a multi-line selection"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1703
                (selectionStartCol ~~ 1) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1704
                    self clearMarginOfVisibleLine:visLine with:bgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1705
                    super redrawVisibleLine:visLine
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1706
                                       from:1
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1707
                                         to:(selectionStartCol - 1)
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1708
                ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1709
                    leftOffset == 0 ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1710
                        self clearMarginOfVisibleLine:visLine with:selectionBgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1711
                    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1712
                ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1713
                self drawVisibleLine:visLine from:selectionStartCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1714
                                with:selectionFgColor and:selectionBgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1715
                ^ self
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1716
            ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1717
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1718
            (line == selectionEndLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1719
                "its the last line of a multi-line selection"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1720
                (selectionEndCol == 0) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1721
                    ^ super redrawVisibleLine:visLine
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1722
                ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1723
                l := self visibleAt:selectionEndLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1724
                len := l size.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1725
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1726
                self clearMarginOfVisibleLine:visLine with:selectionBgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1727
                self drawVisibleLine:visLine from:1 to:selectionEndCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1728
                                with:selectionFgColor and:selectionBgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1729
                super redrawVisibleLine:visLine from:(selectionEndCol + 1).
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1730
                ^ self
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1731
            ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1732
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1733
            "its a full line in a multi-line selection"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1734
            self clearMarginOfVisibleLine:visLine with:selectionBgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1735
            self drawVisibleLine:visLine with:selectionFgColor and:selectionBgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1736
            ^ self
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1737
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1738
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1739
    super redrawVisibleLine:visLine
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1740
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1741
    "Modified: 6.3.1996 / 14:22:19 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1742
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1743
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1744
redrawVisibleLine:visLine col:col
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1745
    "redraw single character at col in visible line lineNr."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1746
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1747
    |line fg bg|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1748
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1749
    line := self visibleLineToAbsoluteLine:visLine.
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1750
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1751
    "/
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1752
    "/ care for selection
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1753
    "/
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1754
    fg := fgColor.
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1755
    bg := bgColor.
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1756
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1757
    selectionStartLine notNil ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1758
        (line between:selectionStartLine and:selectionEndLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1759
            ((line == selectionStartLine)
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1760
            and: [col < selectionStartCol]) ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1761
                ((line == selectionEndLine)
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1762
                and: [col > selectionEndCol]) ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1763
                    "its in the selection"
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1764
                    fg := selectionFgColor.
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1765
                    bg := selectionBgColor.
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1766
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1767
"/                    self 
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1768
"/                        drawVisibleLine:visLine 
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1769
"/                        col:col 
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1770
"/                        with:selectionFgColor
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1771
"/                        and:selectionBgColor.
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1772
"/                    ^ self
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1773
                ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1774
            ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1775
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1776
    ].
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1777
    self drawVisibleLine:visLine col:col with:fg and:bg
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1778
"/    super redrawVisibleLine:visLine col:col
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1779
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1780
    "Modified: 12.5.1996 / 17:46:51 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1781
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1782
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1783
redrawVisibleLine:visLine from:startCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1784
    "redraw visible line lineNr from startCol to end of line"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1785
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1786
    |col line|
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1787
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1788
    col := startCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1789
    col == 0 ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1790
        col := 1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1791
    ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1792
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1793
    line := self visibleLineToAbsoluteLine:visLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1794
    selectionStartLine notNil ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1795
        (line between:selectionStartLine and:selectionEndLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1796
            ((line == selectionStartLine) 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1797
             or:[line == selectionEndLine]) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1798
                "since I'm lazy, redraw full line"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1799
                self redrawVisibleLine:visLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1800
                ^ self
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1801
            ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1802
            "the line is fully within the selection"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1803
            self 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1804
                drawVisibleLine:visLine 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1805
                from:col 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1806
                with:selectionFgColor
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1807
                and:selectionBgColor.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1808
            ^ self
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1809
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1810
    ].
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1811
    super redrawVisibleLine:visLine from:col
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1812
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1813
    "Modified: 6.3.1996 / 14:19:38 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1814
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1815
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1816
redrawVisibleLine:visLine from:startCol to:endCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1817
    "redraw visible line lineNr from startCol to endCol"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1818
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1819
    |line allOut allIn leftCol rightCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1820
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1821
    line := self visibleLineToAbsoluteLine:visLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1822
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1823
    allIn := false.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1824
    allOut := false.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1825
    selectionStartLine isNil ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1826
        allOut := true
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1827
    ] ifFalse:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1828
        (line between:selectionStartLine and:selectionEndLine) ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1829
            allOut := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1830
        ] ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1831
            (selectionStartLine == selectionEndLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1832
                ((endCol < selectionStartCol) 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1833
                or:[startCol > selectionEndCol]) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1834
                    allOut := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1835
                ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1836
                    ((startCol >= selectionStartCol) 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1837
                    and:[endCol <= selectionEndCol]) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1838
                        allIn := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1839
                    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1840
                ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1841
            ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1842
                (line == selectionStartLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1843
                    (endCol < selectionStartCol) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1844
                        allOut := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1845
                    ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1846
                        (startCol >= selectionStartCol) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1847
                            allIn := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1848
                        ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1849
                    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1850
                ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1851
                    (line == selectionEndLine) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1852
                        (startCol > selectionEndCol) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1853
                            allOut := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1854
                        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1855
                            (endCol <= selectionEndCol) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1856
                                allIn := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1857
                            ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1858
                        ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1859
                    ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1860
                        allIn := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1861
                    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1862
                ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1863
            ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1864
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1865
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1866
    allOut ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1867
        super redrawVisibleLine:visLine from:startCol to:endCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1868
        ^ self
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1869
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1870
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1871
    allIn ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1872
        self drawVisibleLine:visLine from:startCol to:endCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1873
                        with:selectionFgColor and:selectionBgColor
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1874
    ] ifFalse:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1875
        "redraw part before selection"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1876
        ((line == selectionStartLine)
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1877
         and:[startCol <= selectionStartCol]) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1878
            super redrawVisibleLine:visLine from:startCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1879
                                              to:(selectionStartCol - 1).
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1880
            leftCol := selectionStartCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1881
        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1882
            leftCol := startCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1883
        ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1884
        "redraw selected part"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1885
        (selectionEndLine > line) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1886
            rightCol := endCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1887
        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1888
            rightCol := selectionEndCol min:endCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1889
        ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1890
        self drawVisibleLine:visLine from:leftCol to:rightCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1891
                        with:selectionFgColor and:selectionBgColor.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1892
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1893
        "redraw part after selection"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1894
        (rightCol < endCol) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1895
            super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1896
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1897
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1898
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1899
    "special care for first and last line of selection:
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1900
     must handle margin also"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1901
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1902
    ((line == selectionEndLine)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1903
    and:[(startCol == 1)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1904
    and:[selectionStartLine < selectionEndLine]])
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1905
    ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1906
        self clearMarginOfVisibleLine:visLine with:selectionBgColor.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1907
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1908
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1909
    ((line == selectionStartLine)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1910
    and:[(startCol == 1)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1911
    and:[selectionStartLine < selectionEndLine]])
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1912
    ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1913
        self clearMarginOfVisibleLine:visLine with:bgColor.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1914
    ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1915
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1916
    "Modified: 6.3.1996 / 14:23:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1917
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1918
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1919
!TextView methodsFor:'searching'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1920
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1921
scanFor:aCharacter fromLine:startLine col:startCol forward:forward
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1922
                     ifFound:foundBlock 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1923
                  ifNotFound:notFoundBlock
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1924
    "search for a character in the direction given by forward. 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1925
     Performs foundBlock with line/col as argument if found, notFoundBlock if not."
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1926
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1927
    |i lineString 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1928
     line   "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1929
     col    "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1930
     delta  "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1931
     endCol "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1932
     cc     
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1933
     maxLine "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1934
      |
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1935
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1936
    col := startCol.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1937
    line := startLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1938
    forward ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1939
        delta := 1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1940
    ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1941
        delta := -1.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1942
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1943
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1944
    lineString := list at:line.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1945
    maxLine := list size.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1946
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1947
    col := col + delta.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1948
    [true] whileTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1949
        lineString notNil ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1950
            forward ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1951
                endCol := lineString size.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1952
            ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1953
                endCol := 1
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1954
            ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1955
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1956
            col to:endCol by:delta do:[:rCol |
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1957
                cc := lineString at:rCol.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1958
                cc == aCharacter ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1959
                    ^ foundBlock value:line value:rCol.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1960
                ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1961
            ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1962
        ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1963
        line := line + delta.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1964
        (line < 1 or:[line > maxLine]) ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1965
            ^ notFoundBlock value
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1966
        ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1967
        lineString := list at:line.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1968
        forward ifTrue:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1969
            col := 1
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1970
        ] ifFalse:[
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1971
            col := lineString size
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1972
        ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1973
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1974
    "not reached"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1975
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1976
    "Modified: 15.10.1996 / 12:22:30 / cg"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1977
    "Created: 11.9.1997 / 04:36:29 / cg"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1978
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1979
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1980
searchBwd
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1981
    "search backward and -if found- position cursor"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1982
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1983
    |ign|
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1984
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1985
    ign := lastSearchIgnoredCase ? false.
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1986
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1987
    self setSearchPattern.
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1988
    lastSearchPattern notNil ifTrue:[
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1989
        self 
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1990
	    searchBwd:lastSearchPattern 
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1991
	    ignoreCase:ign
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1992
    ]
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1993
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1994
    "Modified: 13.9.1997 / 06:24:35 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1995
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1996
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1997
searchBwd:pattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1998
    "do a backward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1999
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2000
    self searchBwd:pattern ifAbsent:[self showNotFound].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2001
    lastSearchIgnoredCase := false.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2002
    lastSearchPattern := pattern
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2003
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2004
    "Modified: 13.9.1997 / 06:20:27 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2005
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2006
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2007
searchBwd:pattern ifAbsent:aBlock
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2008
    "do a backward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2009
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2010
    |startLine startCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2011
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2012
    selectionStartLine notNil ifTrue:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2013
        startLine := selectionStartLine.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2014
        startCol := selectionStartCol
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2015
    ] ifFalse:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2016
        startLine := 1.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2017
        startCol := 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2018
    ].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2019
    self 
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2020
        searchBackwardFor:pattern startingAtLine:startLine col:startCol
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2021
        ifFound:[:line :col | self showMatch:pattern atLine:line col:col] 
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2022
        ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2023
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2024
    "Modified: 13.9.1997 / 01:05:49 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2025
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2026
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2027
searchBwd:pattern ignoreCase:ign
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2028
    "do a backward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2029
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2030
    self searchBwd:pattern ignoreCase:ign ifAbsent:[self showNotFound].
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2031
    lastSearchIgnoredCase := ign.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2032
    lastSearchPattern := pattern
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2033
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2034
    "Created: 13.9.1997 / 06:18:00 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2035
    "Modified: 13.9.1997 / 06:20:33 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2036
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2037
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2038
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2039
    "do a backward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2040
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2041
    |startLine startCol|
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2042
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2043
    selectionStartLine notNil ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2044
        startLine := selectionStartLine.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2045
        startCol := selectionStartCol
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2046
    ] ifFalse:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2047
        startLine := 1.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2048
        startCol := 1
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2049
    ].
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2050
    self 
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2051
        searchBackwardFor:pattern 
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2052
        ignoreCase:ign
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2053
        startingAtLine:startLine col:startCol
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2054
        ifFound:[:line :col | self showMatch:pattern atLine:line col:col] 
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2055
        ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2056
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2057
    "Modified: 13.9.1997 / 01:05:49 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2058
    "Created: 13.9.1997 / 06:18:41 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2059
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2060
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2061
searchForMatchingParenthesisFromLine:startLine col:startCol
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2062
                     ifFound:foundBlock 
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2063
                  ifNotFound:notFoundBlock
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2064
                     onError:failBlock
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2065
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2066
    "search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2067
     Search for the corresponding character is done forward if its an opening,
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2068
     backwards if its a closing parenthesis.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2069
     Performs foundBlock with line/col as argument if found, notFoundBlock if not.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2070
     If there is a nesting error, performs failBlock."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2071
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2072
    ^ self
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2073
        searchForMatchingParenthesisFromLine:startLine col:startCol
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2074
                     ifFound:foundBlock 
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2075
                  ifNotFound:notFoundBlock
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2076
                     onError:failBlock
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2077
                    ignoring:#( $' $" '$[' '$]' '${' '$)' )
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2078
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2079
    "Modified: 18.5.1996 / 11:05:57 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2080
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2081
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2082
searchForMatchingParenthesisFromLine:startLine col:startCol
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2083
                     ifFound:foundBlock 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2084
                  ifNotFound:notFoundBlock
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2085
                     onError:failBlock
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2086
                    ignoring:ignoreSet
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2087
    "search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2088
     Search for the corresponding character is done forward if its an opening,
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2089
     backwards if its a closing parenthesis.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2090
     Performs foundBlock with line/col as argument if found, notFoundBlock if not.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2091
     If there is a nesting error, performs failBlock."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2092
770
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2093
    |i direction lineString 
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2094
     parChar charSet  closingChar 
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2095
     ignoring 
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2096
     line   "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2097
     col    "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2098
     delta  "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2099
     endCol "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2100
     runCol "{ Class: SmallInteger }"
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2101
     cc prevCC nextCC incSet decSet 
770
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2102
     nesting "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2103
     maxLine "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2104
     ign skip|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2105
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2106
    charSet := #( $( $) $[ $] ${ $} " $< $> " ).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2107
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2108
    parChar := self characterAtLine:startLine col:startCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2109
    i := charSet indexOf:parChar.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2110
    i == 0 ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2111
        ^ failBlock value   "not a parenthesis"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2112
    ].
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2113
    direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2114
    closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2115
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2116
    col := startCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2117
    line := startLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2118
    direction == #fwd ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2119
        delta := 1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2120
        incSet := #( $( $[ ${ "$<" ).
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2121
        decSet := #( $) $] $} "$>" ).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2122
    ] ifFalse:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2123
        delta := -1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2124
        incSet := #( $) $] $} "$>" ).
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2125
        decSet := #( $( $[ ${ "$<" ).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2126
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2127
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2128
    nesting := 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2129
    ignoring := false.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2130
    lineString := list at:line.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2131
    maxLine := list size.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2132
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2133
    col := col + delta.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2134
    [nesting ~~ 0] whileTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2135
        lineString notNil ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2136
            direction == #fwd ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2137
                endCol := lineString size.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2138
            ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2139
                endCol := 1
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2140
            ].
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2141
770
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2142
            col to:endCol by:delta do:[:rCol |
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2143
                runCol := rCol.
770
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  2144
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2145
                cc := lineString at:runCol.
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2146
                runCol < lineString size ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2147
                    nextCC := lineString at:runCol+1
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2148
                ] ifFalse:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2149
                    nextCC := nil
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2150
                ].
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2151
                runCol > 1 ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2152
                    prevCC := lineString at:runCol-1
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2153
                ] ifFalse:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2154
                    prevCC := nil
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2155
                ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2156
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2157
                ign := skip := false.
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2158
                (cc == $"   
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2159
                and:[nextCC == $/ or:[prevCC == $$ ]]) ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2160
                    "/ do nothing
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2161
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2162
                    skip := true.
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2163
                ] ifFalse:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2164
                    ignoreSet do:[:ignore |
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2165
                        ignore == cc ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2166
                            ign := true
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2167
                        ] ifFalse:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2168
                            ignore isString ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2169
                                cc == (ignore at:2) ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2170
                                    runCol > 1 ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2171
                                        (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2172
                                            skip := true
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2173
                                        ]
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2174
                                    ]
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2175
                                ] ifFalse:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2176
                                    cc == (ignore at:1) ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2177
                                        runCol < lineString size ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2178
                                            (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2179
                                                skip := true
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2180
                                            ]
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2181
                                        ]
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2182
                                    ]
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2183
                                ]
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2184
                            ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2185
                        ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2186
                    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2187
                ].
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2188
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2189
                ign ifTrue:[
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2190
                    ignoring := ignoring not
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2191
                ].
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2192
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2193
                ignoring ifFalse:[
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2194
                    skip ifFalse:[
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2195
                        (incSet includes:cc) ifTrue:[
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2196
                            nesting := nesting + 1
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2197
                        ] ifFalse:[
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2198
                            (decSet includes:cc) ifTrue:[
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2199
                                nesting := nesting - 1
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2200
                            ]
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2201
                        ]
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2202
                    ]
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2203
                ].
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2204
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2205
                nesting == 0 ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2206
                    "check if legal"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2207
651
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2208
                    skip ifFalse:[
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2209
                        cc == closingChar ifFalse:[
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2210
                            ^ failBlock value
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2211
                        ].
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2212
                        ^ foundBlock value:line value:runCol.
1e7153e21b36 skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
  2213
                    ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2214
                ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2215
            ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2216
        ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2217
        line := line + delta.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2218
        (line < 1 or:[line > maxLine]) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2219
            ^ failBlock value
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2220
        ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2221
        lineString := list at:line.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2222
        direction == #fwd ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2223
            col := 1
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2224
        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2225
            col := lineString size
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2226
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2227
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2228
    ^ notFoundBlock value
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2229
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2230
    "Modified: 15.10.1996 / 12:22:30 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2231
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2232
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2233
searchFwd
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2234
    "search forward for pattern or selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2235
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2236
    |ign|
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2237
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2238
    ign := lastSearchIgnoredCase ? false.
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2239
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2240
    selectStyle == #wordLeft ifTrue:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2241
        "
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2242
         remove the space from the selection
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2243
        "
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2244
        selectionStartCol := selectionStartCol + 1.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2245
        super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2246
        selectStyle := #word.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2247
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2248
    self setSearchPattern.
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2249
    lastSearchPattern notNil ifTrue:[
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2250
        self 
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2251
	    searchFwd:lastSearchPattern
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2252
	    ignoreCase:ign
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2253
    ]
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2254
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2255
    "Modified: 13.9.1997 / 06:24:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2256
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2257
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2258
searchFwd:pattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2259
    "do a forward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2260
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2261
    self searchFwd:pattern ifAbsent:[self showNotFound].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2262
    lastSearchIgnoredCase := false.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2263
    lastSearchPattern := pattern
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2264
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2265
    "Modified: 13.9.1997 / 06:20:43 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2266
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2267
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2268
searchFwd:pattern ifAbsent:aBlock
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2269
    "do a forward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2270
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2271
    |startLine startCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2272
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2273
    selectionStartLine notNil ifTrue:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2274
        startLine := selectionStartLine.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2275
        startCol := selectionStartCol
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2276
    ] ifFalse:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2277
        startLine := 1.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2278
        startCol := 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2279
    ].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2280
    self 
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2281
        searchForwardFor:pattern startingAtLine:startLine col:startCol
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2282
        ifFound:[:line :col | self showMatch:pattern atLine:line col:col]
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2283
        ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2284
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2285
    "Modified: 13.9.1997 / 01:05:35 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2286
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2287
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2288
searchFwd:pattern ignoreCase:ign
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2289
    "do a forward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2290
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2291
    self searchFwd:pattern ignoreCase:ign ifAbsent:[self showNotFound].
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2292
    lastSearchIgnoredCase := ign.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2293
    lastSearchPattern := pattern
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2294
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2295
    "Created: 13.9.1997 / 06:18:13 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2296
    "Modified: 13.9.1997 / 06:20:37 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2297
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2298
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2299
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2300
    "do a forward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2301
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2302
    |startLine startCol|
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2303
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2304
    selectionStartLine notNil ifTrue:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2305
        startLine := selectionStartLine.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2306
        startCol := selectionStartCol
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2307
    ] ifFalse:[
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2308
        startLine := 1.
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2309
        startCol := 1
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2310
    ].
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2311
    self 
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2312
        searchForwardFor:pattern 
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2313
        ignoreCase:ign
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2314
        startingAtLine:startLine col:startCol
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2315
        ifFound:[:line :col | self showMatch:pattern atLine:line col:col]
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2316
        ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2317
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2318
    "Modified: 13.9.1997 / 01:05:35 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2319
    "Created: 13.9.1997 / 06:18:27 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2320
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2321
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2322
searchPattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2323
    "return the last search pattern"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2324
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2325
    ^ lastSearchPattern
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2326
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2327
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2328
setSearchPattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2329
    "set the searchpattern from the selection if there is one"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2330
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2331
    |sel|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2332
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2333
    sel := self selection.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2334
    sel notNil ifTrue:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2335
	lastSearchPattern := sel asString withoutSeparators
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2336
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2337
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2338
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2339
setSearchPattern:aString
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2340
    "set the searchpattern for future searches"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2341
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2342
    aString isNil ifTrue:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2343
	lastSearchPattern := aString
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2344
    ] ifFalse:[
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2345
	lastSearchPattern := aString withoutSeparators
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2346
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2347
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2348
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2349
showMatch:pattern atLine:line col:col
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2350
    "after a search, highlight the matched pattern.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2351
     The code below needs a rewrite to take care of match-characters
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2352
     (for now, it only highlights simple patterns and '*string*' correctly)"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2353
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2354
    |realPattern|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2355
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2356
    realPattern := pattern.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2357
    (realPattern startsWith:$*) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2358
	realPattern := realPattern copyFrom:2
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2359
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2360
    (realPattern endsWith:$*) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2361
	realPattern := realPattern copyWithoutLast:1
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2362
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2363
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2364
    self selectFromLine:line col:col
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2365
		 toLine:line col:(col + realPattern size - 1).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2366
    self makeLineVisible:line
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2367
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2368
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2369
showNotFound
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2370
    "search not found - tell user by beeping and changing
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2371
     cursor for a while (sometimes I work with a headset :-)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2372
     (used to be: tell user by changing cursor for a while)"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2373
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2374
    |savedCursor|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2375
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2376
    savedCursor := cursor.
1028
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2377
    [
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2378
        self cursor:(Cursor cross).
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2379
        self beep.
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2380
        Processor activeProcess millisecondDelay:300.
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2381
    ] valueNowOrOnUnwindDo:[
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2382
        self cursor:savedCursor
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2383
    ]
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2384
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  2385
    "Modified: 20.2.1997 / 12:49:27 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2386
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2387
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2388
!TextView methodsFor:'selections'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2389
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2390
expandSelectionDown
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2391
    |l t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2392
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2393
    selectionStartLine notNil ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2394
        expandingTop ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2395
            l := selectionStartLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2396
            selectionStartLine := selectionStartLine + 1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2397
            (selectionStartLine > clickLine
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2398
            or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]])
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2399
            ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2400
                t := selectionStartLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2401
                selectionStartLine := selectionEndLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2402
                selectionEndLine := t.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2403
                t := selectionStartCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2404
                selectionStartCol := selectionEndCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2405
                selectionEndCol := t.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2406
                expandingTop := false
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2407
            ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2408
        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2409
            l := selectionEndLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2410
            selectionEndLine := selectionEndLine + 1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2411
        ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2412
        self redrawLine:l. 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2413
        self redrawLine:l+1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2414
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2415
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2416
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2417
    "Created: 1.3.1996 / 23:35:08 / cg"
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2418
    "Modified: 18.3.1996 / 17:18:15 / cg"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2419
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2420
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2421
expandSelectionLeft
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2422
    |c l t c1 c2|
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2423
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2424
    selectionStartLine notNil ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2425
        expandingTop ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2426
            selectionStartCol == 0 ifTrue:[^ self].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2427
            l := selectionStartLine.
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2428
            selectionStartCol := (selectionStartCol - 1) max:1.
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2429
            c := selectionStartCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2430
        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2431
            l := selectionEndLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2432
            selectionEndCol := (selectionEndCol - 1) max:0.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2433
            c := selectionEndCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2434
            selectionEndLine == selectionStartLine ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2435
                selectionEndCol <= selectionStartCol ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2436
                    t := selectionStartCol. selectionStartCol := selectionEndCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2437
                    selectionEndCol := t.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2438
                    expandingTop := true.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2439
                    c := selectionStartCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2440
                ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2441
            ].
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2442
        ].
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2443
        c1 := c.
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2444
        c2 := c1 + 1.
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2445
        c1 == 0 ifTrue:[
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2446
            c1 := 1
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2447
        ].
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2448
        self redrawLine:l from:c1 to:c2. 
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2449
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2450
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2451
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  2452
    "Modified: 18.3.1996 / 17:05:46 / cg"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2453
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2454
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2455
expandSelectionRight
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2456
    |l c t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2457
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2458
    selectionStartLine notNil ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2459
        expandingTop ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2460
            l := selectionStartLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2461
            c := selectionStartCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2462
            selectionStartCol := selectionStartCol + 1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2463
            l == selectionEndLine ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2464
                c >= selectionEndCol ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2465
                    expandingTop := false.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2466
                    t := selectionStartCol. selectionStartCol := selectionEndCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2467
                    selectionEndCol := t.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2468
                    c := selectionStartCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2469
                ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2470
            ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2471
        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2472
            l := selectionEndLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2473
            c := selectionEndCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2474
            selectionEndCol := selectionEndCol + 1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2475
        ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2476
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2477
        self redrawLine:l from:c to:c+1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2478
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2479
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2480
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2481
    "Created: 1.3.1996 / 23:33:17 / cg"
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2482
    "Modified: 6.3.1996 / 13:54:10 / cg"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2483
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2484
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2485
expandSelectionUp
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2486
    |l t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2487
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2488
    selectionStartLine notNil ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2489
        expandingTop ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2490
            selectionStartLine := (selectionStartLine - 1) max:1.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2491
            l := selectionStartLine. 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2492
        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2493
            selectionEndLine := (selectionEndLine - 1) max:0.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2494
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2495
            l := selectionEndLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2496
            (selectionEndLine < clickLine
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2497
            or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])])
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2498
            ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2499
                t := selectionStartLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2500
                selectionStartLine := selectionEndLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2501
                selectionEndLine := t.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2502
                t := selectionStartCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2503
                selectionStartCol := selectionEndCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2504
                selectionEndCol := t.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2505
                l := selectionStartLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2506
                expandingTop := true
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2507
            ].
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2508
        ].
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2509
        self redrawLine:l. 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2510
        self redrawLine:l+1. 
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2511
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2512
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2513
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2514
    "Modified: 6.3.1996 / 14:12:06 / cg"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2515
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2516
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2517
hasSelection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2518
    "return true, if there is a selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2519
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2520
    ^ selectionStartLine notNil
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2521
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2522
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2523
makeSelectionVisible
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2524
    "scroll to make the selection visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2525
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2526
    |line col|
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2527
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2528
    selectionStartLine notNil ifTrue:[
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2529
        expandingTop ~~ false ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2530
            line := selectionStartLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2531
            col := selectionStartCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2532
        ] ifFalse:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2533
            line := selectionEndLine.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2534
            col := selectionEndCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2535
        ].
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2536
        self makeLineVisible:line.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2537
        self makeColVisible:col inLine:line.        
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2538
    ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2539
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2540
    "Modified: 6.3.1996 / 13:53:45 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2541
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2542
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2543
selectAll
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2544
    "select the whole text"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2545
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2546
    self selectFromLine:1 col:1 toLine:(list size + 1) col:0
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2547
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2548
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2549
selectFromCharacterPosition:pos1 to:pos2
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2550
    "compute line/col from character positions and select the text"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2551
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2552
    |line1 col1 line2 col2|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2553
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2554
    line1 := self lineOfCharacterPosition:pos1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2555
    col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2556
    line2 := self lineOfCharacterPosition:pos2.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2557
    col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2558
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2559
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2560
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2561
selectFromLine:startLine col:startCol toLine:endLine col:endCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2562
    "select a piece of text and redraw that area"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2563
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2564
    self unselect.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2565
    startLine notNil ifTrue:[
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2566
        "new:"
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2567
        endLine < startLine ifTrue:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2568
            ^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2569
        ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2570
        (endLine == startLine and:[endCol < startCol]) ifTrue:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2571
            endCol ~~ 0 ifTrue:[
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2572
                self selectFromLine:endLine col:endCol toLine:startLine col:startCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2573
            ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2574
            ^ self
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2575
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2576
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2577
" old:
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2578
        endLine < startLine ifTrue:[^ self].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2579
        (startLine == endLine and:[endCol < startCol]) ifTrue:[^ self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2580
"
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2581
        selectionStartLine := startLine.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2582
        selectionStartCol := startCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2583
        selectionEndLine := endLine.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2584
        selectionEndCol := endCol.
904
597bf5cfe653 care for changed selection from #validateNewSelection
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  2585
        self validateNewSelection.
597bf5cfe653 care for changed selection from #validateNewSelection
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  2586
597bf5cfe653 care for changed selection from #validateNewSelection
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  2587
        (selectionStartLine == selectionEndLine) ifTrue:[
597bf5cfe653 care for changed selection from #validateNewSelection
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  2588
            self redrawLine:selectionStartLine from:selectionStartCol to:selectionEndCol
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2589
        ] ifFalse:[
904
597bf5cfe653 care for changed selection from #validateNewSelection
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  2590
            selectionStartLine to:selectionEndLine do:[:lineNr |
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2591
                self redrawLine:lineNr
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2592
            ]
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2593
        ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2594
        selectStyle := nil.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2595
    ]
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2596
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2597
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2598
     |v|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2600
     v := TextView extent:300@300.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2601
     v contents:('smalltalk.rc' asFilename contentsOfEntireFile).
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2602
     v openAndWait.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2603
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2604
     Delay waitForSeconds:1.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2605
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2606
     v selectFromLine:2 col:2 toLine:10 col:15
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2607
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2608
904
597bf5cfe653 care for changed selection from #validateNewSelection
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  2609
    "Modified: 2.1.1997 / 13:32:25 / cg"
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2610
!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2611
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2612
selectFromLine:startLine toLine:endLine
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2613
    "select a piece of text and redraw that area"
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2614
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2615
    self selectFromLine:startLine col:1 toLine:endLine+1 col:0
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2616
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2617
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2618
     |v|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2619
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2620
     v := TextView extent:300@300.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2621
     v contents:('smalltalk.rc' asFilename contentsOfEntireFile).
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2622
     v openAndWait.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2623
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2624
     Delay waitForSeconds:1.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2625
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2626
     v selectFromLine:2 toLine:10
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2627
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2628
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2629
    "Modified: 29.4.1996 / 12:23:46 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2630
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2631
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2632
selectLine:selectLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2633
    "select one line and redraw it"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2634
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2635
    self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2636
    wordStartCol := selectionStartCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2637
    wordEndCol := selectionEndCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2638
    wordStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2639
    wordEndLine := selectionEndLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2640
    selectStyle := #line
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2641
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2642
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2643
selectLineAtY:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2644
    "select the line at given y-(view-)coordinate"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2645
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2646
    |selectVisibleLine selectLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2647
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2648
    selectVisibleLine := self visibleLineOfY:y.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2649
    selectLine := self visibleLineToListLine:selectVisibleLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2650
    selectLine notNil ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2651
	self selectLine:selectLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2652
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2653
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2654
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2655
selectLineWhereCharacterPosition:pos
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2656
    "select the line, where characterPosition pos is living.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2657
     The argument pos starts at 1 from the start of the text
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2658
     and counts characters (i.e. can be used to convert from 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2659
     character position within a string to line-position in view)."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2660
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2661
    self selectLine:(self lineOfCharacterPosition:pos)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2662
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2663
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2664
selectWordAtLine:line col:col
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2665
    "select the word at given line/col"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2666
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2667
    self wordAtLine:line col:col do:[
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  2668
        :beginLine :beginCol :endLine :endCol :style |
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2669
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  2670
        self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  2671
        selectStyle := style
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2672
    ]
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  2673
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  2674
    "Modified: 18.3.1996 / 17:30:38 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2675
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2676
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2677
selectWordAtX:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2678
    "select the word at given x/y-(view-)coordinate"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2679
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2680
    |selectVisibleLine selectLine selectCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2681
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2682
    selectStyle := nil.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2683
    selectVisibleLine := self visibleLineOfY:y.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2684
    selectLine := self visibleLineToListLine:selectVisibleLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2685
    selectLine notNil ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2686
	selectCol := self colOfX:x inVisibleLine:selectLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2687
	self selectWordAtLine:selectLine col:selectCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2688
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2689
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2690
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2691
selection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2692
    "return the selection as a collection of (line-)strings.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2693
     If the selection ends in a full line, the last entry in the returned
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2694
     collection will be an empty string."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2695
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2696
    |text sz index last
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2697
     startLine "{ Class: SmallInteger }"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2698
     endLine   "{ Class: SmallInteger }"|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2699
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2700
    selectionStartLine isNil ifTrue:[^ nil].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2701
    startLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2702
    endLine := selectionEndLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2703
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2704
    (startLine == endLine) ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2705
	"part of a line"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2706
	^ StringCollection with:(self listAt:startLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2707
					from:selectionStartCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2708
					  to:selectionEndCol)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2709
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2710
    sz := endLine - startLine + 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2711
    text := StringCollection new:sz.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2712
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2713
    "get 1st and last (possibly) partial lines"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2714
    text at:1 put:(self listAt:startLine from:selectionStartCol).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2715
    selectionEndCol == 0 ifTrue:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2716
	last := ''
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2717
    ] ifFalse:[
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2718
	last := self listAt:selectionEndLine to:selectionEndCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2719
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2720
    text at:sz put:last.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2721
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2722
    "get bulk of text"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2723
    index := 2.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2724
    (startLine + 1) to:(endLine - 1) do:[:lineNr |
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2725
	text at:index put:(self listAt:lineNr).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2726
	index := index + 1
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2727
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2728
    ^ text
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2729
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2730
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2731
selectionEndCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2732
    ^ selectionEndCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2733
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2734
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2735
selectionEndLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2736
    ^ selectionEndLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2737
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2738
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2739
selectionStartCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2740
    ^ selectionStartCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2741
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2742
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2743
selectionStartLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2744
    ^ selectionStartLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2745
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2746
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2747
unselect
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2748
    "unselect - if there was a selection redraw that area"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2749
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2750
    |startLine endLine startVisLine endVisLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2751
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2752
    selectionStartLine notNil ifTrue:[
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2753
        startLine := selectionStartLine.
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2754
        endLine := selectionEndLine.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2755
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2756
        self unselectWithoutRedraw.
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2757
715
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2758
        "/ if the selection is not visible, we are done
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2759
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2760
        startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self].
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2761
        endLine < firstLineShown ifTrue:[^ self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2762
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2763
        startLine < firstLineShown ifTrue:[
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2764
            startVisLine := 1
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2765
        ] ifFalse:[
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2766
            startVisLine := self listLineToVisibleLine:startLine
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2767
        ].
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2768
        endLine >= (firstLineShown + nLinesShown) ifTrue:[
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2769
            endVisLine := nLinesShown
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2770
        ] ifFalse:[
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2771
            endVisLine := self listLineToVisibleLine:endLine
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2772
        ].
715
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2773
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2774
        "/ if its only part of a line, just redraw what has to be
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2775
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2776
        (startLine == endLine) ifTrue:[
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2777
            super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2778
        ] ifFalse:[
715
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2779
            self redrawFromVisibleLine:startVisLine to:endVisLine
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2780
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2781
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2782
    selectStyle := nil
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  2783
715
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2784
    "Modified: 29.5.1996 / 14:54:11 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2785
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2786
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2787
unselectWithoutRedraw
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2788
    "forget selection but do not redraw the selection area
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2789
     - can be done when the selected area is redrawn anyway or
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2790
     known to be invisible (however, redraw knows about that anyway)."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2791
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2792
    selectionStartLine := nil.
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2793
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2794
    "Modified: 29.4.1996 / 12:33:28 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2795
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2796
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2797
validateNewSelection
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2798
     "make certain that the selection is valid.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2799
      This is a dummy here, but subclasses (like single-line editFields)
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2800
      may redefine it to limit the selection to a single line, or whatever."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2801
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2802
    ^ self
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  2803
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2804
    "Modified: 29.4.1996 / 12:32:08 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2805
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2806
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2807
!TextView class methodsFor:'documentation'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2808
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2809
version
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2810
    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.109 1997-10-21 18:03:14 cg Exp $'
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2811
! !