TextView.st
author Claus Gittinger <cg@exept.de>
Tue, 08 Jul 2014 23:39:46 +0200
changeset 5099 1af2798f1150
parent 5094 520a8c202db3
child 5113 d5f95ba1494b
permissions -rw-r--r--
class: TextView changed: #initStyle (send #gray instead of #grey)
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
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
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
"
2191
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    12
"{ Package: 'stx:libwidg' }"
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    13
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    14
ListView subclass:#TextView
3394
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    15
	instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    16
		selectionEndCol clickPos clickStartLine clickStartCol clickLine
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    17
		clickCol clickCount expandingTop wordStartCol wordStartLine
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    18
		wordEndCol wordEndLine selectionFgColor selectionBgColor
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    19
		selectStyle directoryForFileDialog defaultFileNameForFileDialog
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    20
		externalEncoding contentsWasSaved searchAction lastSearchPattern
3964
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
    21
		lastSearchWasMatch lastSearchIgnoredCase lastSearchDirection
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
    22
		lastSearchWasVariableSearch parenthesisSpecification dropSource
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
    23
		dragIsActive saveAction st80SelectMode searchBarActionBlock'
3394
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    24
	classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    25
		DefaultSelectionBackgroundColor
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    26
		DefaultAlternativeSelectionForegroundColor
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    27
		DefaultAlternativeSelectionBackgroundColor MatchDelayTime
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    28
		WordSelectCatchesBlanks LastSearchPatterns
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    29
		NumRememberedSearchPatterns LastSearchIgnoredCase
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
    30
		LastSearchWasMatch DefaultParenthesisSpecification'
3394
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    31
	poolDictionaries:''
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    32
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    33
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    34
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    35
!TextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    36
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    37
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    38
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    39
 COPYRIGHT (c) 1989 by Claus Gittinger
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    40
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    41
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    42
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    43
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    44
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    45
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    46
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    47
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    48
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    49
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    50
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
    51
documentation
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    52
"
120
claus
parents: 119
diff changeset
    53
    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
    54
    The text is not editable and there is no cursor.
120
claus
parents: 119
diff changeset
    55
    Use TextViews for readonly text, EditTextView for editable text.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    56
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
    57
    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
    58
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    59
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    60
120
claus
parents: 119
diff changeset
    61
      selectionStartLine      <Number>                the line of the selection start (or nil)
claus
parents: 119
diff changeset
    62
      selectionStartCol       <Number>                the col of the selection start
claus
parents: 119
diff changeset
    63
      selectionEndLine        <Number>                the line of the selection end
claus
parents: 119
diff changeset
    64
      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
    65
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    66
      clickStartLine          <Number>                temporary - remember where select operation started
120
claus
parents: 119
diff changeset
    67
      clickStartCol           <Number>                temporary
claus
parents: 119
diff changeset
    68
      clickLine               <Number>                temporary
claus
parents: 119
diff changeset
    69
      clickCol                <Number>                temporary
claus
parents: 119
diff changeset
    70
      clickCount              <Number>                temporary
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    71
      expandingTop            <Boolean>               temporary - for expandSelection
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    72
120
claus
parents: 119
diff changeset
    73
      selectionFgColor        <Color>                 color used to draw selections
claus
parents: 119
diff changeset
    74
      selectionBgColor        <Color>                 color used to draw selections
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    75
120
claus
parents: 119
diff changeset
    76
      selectStyle             <Symbol>                how words are selected
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    77
120
claus
parents: 119
diff changeset
    78
      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
    79
120
claus
parents: 119
diff changeset
    80
      contentsWasSaved        <Boolean>               set to true, whenever saved in a file
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    81
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    82
      externalEncoding        <Symbol|nil>            external encoding, used when text is saved to
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    83
						      a file. Usually something like
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    84
						      #jis7, #euc, #sjis etc.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    85
						      (currently only passed down from the
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    86
						       fileBrowser)
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
    87
96256221e3af support drag
ca
parents: 2581
diff changeset
    88
      dropSource              <DropSource>            drag operation descriptor or nil (dragging disabled)
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    89
      dragIsActive            <Boolean>               true, drag operation is activated
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    90
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    91
      searchAction            <Block>                 an autosearch action; typically set by the browser.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    92
						      Will be used as default when searchFwd/searchBwd is
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    93
						      pressed. If the searchPattern is changed, no autosearch
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    94
						      action will be executed.
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    95
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    96
      searchBarActionBlock    <Block>                 search action block for embedded search
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
    97
						      panel. Used as second chance for searchFwd/bwd
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    98
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    99
    [class variables:]
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   100
	ST80Selections        <Boolean>               enables ST80 style doubleclick behavior
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   101
						      (right after opening parenthesis, right before
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   102
						       closing parenthesis, at begin of a line
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   103
						       at begin of text)
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   104
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   105
    [StyleSheet parameters:]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   106
2600
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   107
      textView.background                       defaults to viewBackground
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   108
      textView.ViewFont                         defaults to textFont
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   109
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   110
      text.st80Selections                       st80 behavior (click on char after parent or quote)
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   111
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   112
      text.selectionForegroundColor             defaults to textBackgroundColor
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   113
      text.selectionBackgroundColor             defaults to textForegroundColor
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   114
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   115
      text.alternativeSelectionForegroundColor  pasted text (i.e. paste will not replace)
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   116
						defaults to selectionForegroundColor
2600
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   117
      text.alternativeSelectionBackgroundColor  pasted text (i.e. paste will not replace)
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   118
						defaults to selectionBackgroundColor
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   119
    [author:]
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   120
	Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   121
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   122
    [see also:]
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   123
	EditTextView CodeView Workspace
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   124
"
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   125
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   126
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   127
examples
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   128
"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   129
    although textViews (and instances of subclasses) are mostly used
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   130
    as components (in the fileBrowser, the browser, the launcher etc.),
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   131
    they may also be opened as a textEditor;
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   132
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   133
    open a (readonly) textView on some information text:
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   134
							[exBegin]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   135
	TextView
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   136
	    openWith:'read this'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   137
	    title:'demonstration'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   138
							[exEnd]
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   139
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   140
    the same, but open it modal:
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   141
							[exBegin]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   142
	TextView
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   143
	    openModalWith:'read this first'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   144
	    title:'demonstration'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   145
							[exEnd]
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   146
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   147
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   148
    open it modal (but editable) on some text:
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   149
    (must accept before closing)
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   150
    This is somewhat kludgy - when closed, the view has already
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   151
    nilled its link to the model. Therefore, the accept must be
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   152
    done 'manually' below.
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   153
    However, usually an applicationModel is installed as the
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   154
    editor-topViews application. This would get a closeRequest,
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   155
    where it could handle things.
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   156
							[exBegin]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   157
	|m textView|
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   158
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   159
	m := 'read this first' asValue.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   160
	textView := EditTextView openModalOnModel:m.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   161
	textView modified ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   162
	    (self confirm:'text was not accepted - do it now ?')
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   163
	    ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   164
		m value:textView contents
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   165
	    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   166
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   167
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   168
	Transcript showCR:m value.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   169
							[exEnd]
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   170
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   171
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   172
    open a textEditor on some file:
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   173
							[exBegin]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   174
	EditTextView openOn:'Makefile'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   175
							[exEnd]
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   176
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   177
"
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   178
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   179
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   180
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   181
!TextView class methodsFor:'instance creation'!
119
claus
parents: 97
diff changeset
   182
claus
parents: 97
diff changeset
   183
on:aModel aspect:aspect change:change menu:menu initialSelection:initial
claus
parents: 97
diff changeset
   184
    "for ST-80 compatibility"
claus
parents: 97
diff changeset
   185
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   186
    ^ (self new)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   187
	on:aModel
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   188
	aspect:aspect
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   189
	list:aspect
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   190
	change:change
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   191
	menu:menu
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   192
	initialSelection:initial
3280
703642244271 +with:someText (VW-compat.)
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   193
!
703642244271 +with:someText (VW-compat.)
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   194
703642244271 +with:someText (VW-compat.)
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   195
with:someText
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   196
    ^ (self new)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   197
	contents:someText
119
claus
parents: 97
diff changeset
   198
! !
claus
parents: 97
diff changeset
   199
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   200
!TextView class methodsFor:'class initialization'!
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   201
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   202
initialize
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   203
    DefaultParenthesisSpecification isNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   204
	DefaultParenthesisSpecification := IdentityDictionary new.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   205
	DefaultParenthesisSpecification at:#open        put:#( $( $[ ${ "$> $<") .
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   206
	DefaultParenthesisSpecification at:#close       put:#( $) $] $} "$> $<").
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   207
	DefaultParenthesisSpecification at:#ignore      put:#( $' $" '$[' '$]' '${' '$)' ).
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   208
	DefaultParenthesisSpecification at:#eolComment  put:'"/'.     "/ sigh - must be 2 characters
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   209
    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   210
! !
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   211
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   212
!TextView class methodsFor:'defaults'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   213
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   214
defaultIcon
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   215
    "return the default icon if started as a topView"
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   216
3496
8c92a96c4e27 icon resource
Claus Gittinger <cg@exept.de>
parents: 3491
diff changeset
   217
    <resource: #programImage>
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   218
    <resource: #style (#ICON #ICON_FILE)>
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   219
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   220
    |nm i|
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   221
1146
027884518745 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   222
    i := self classResources at:'ICON' default:nil.
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   223
    i isNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   224
	nm := ClassResources at:'ICON_FILE' default:'Editor.xbm'.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   225
	i := Smalltalk imageFromFileNamed:nm forClass:self.
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   226
    ].
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   227
    i notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   228
	i := i onDevice:Display
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   229
    ].
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   230
    ^ i
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   231
3496
8c92a96c4e27 icon resource
Claus Gittinger <cg@exept.de>
parents: 3491
diff changeset
   232
    "Modified: / 17-09-2007 / 11:36:29 / cg"
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   233
!
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   234
910
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   235
defaultMenuMessage
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   236
    "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
   237
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   238
    ^ #editMenu
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   239
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   240
    "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
   241
!
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   242
4254
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   243
defaultParenthesisSpecification
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   244
    ^ DefaultParenthesisSpecification
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   245
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   246
    "Created: / 14-06-2011 / 14:00:59 / cg"
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   247
!
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   248
2306
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   249
defaultSelectionBackgroundColor
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   250
    "return the default selection background color"
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   251
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   252
    ^DefaultSelectionBackgroundColor
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   253
!
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   254
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   255
defaultSelectionForegroundColor
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   256
    "return the default selection foreground color"
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   257
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   258
    ^DefaultSelectionForegroundColor
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   259
!
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   260
1477
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   261
defaultViewBackgroundColor
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   262
    "return the default view background"
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   263
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   264
    ^DefaultViewBackground
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   265
!
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   266
3226
43c19d2a074d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   267
lastSearchIgnoredCase
43c19d2a074d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   268
    ^ LastSearchIgnoredCase
43c19d2a074d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   269
!
43c19d2a074d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   270
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   271
lastSearchWasMatch
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   272
    ^ LastSearchWasMatch
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   273
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   274
1729
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   275
st80SelectMode
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   276
    ^ UserPreferences current st80SelectMode
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   277
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   278
    "Modified: / 03-07-2006 / 16:26:44 / cg"
1729
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   279
!
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   280
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   281
st80SelectMode:aBoolean
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   282
    UserPreferences current st80SelectMode:aBoolean
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   283
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   284
    "Created: / 07-01-1999 / 13:35:24 / cg"
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   285
    "Modified: / 03-07-2006 / 16:27:01 / cg"
1729
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   286
!
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   287
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   288
updateStyleCache
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   289
    "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
   290
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   291
    <resource: #style (#'textView.background'
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   292
		       #'text.selectionForegroundColor'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   293
		       #'text.selectionBackgroundColor'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   294
		       #'text.alternativeSelectionForegroundColor'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   295
		       #'text.alternativeSelectionBackgroundColor'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   296
		       #'textView.font'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   297
		       #'text.wordSelectCatchesBlanks'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   298
		       #'text.st80Selections')>
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   299
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   300
    DefaultViewBackground := StyleSheet colorAt:'textView.background' default:White.
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
   301
    DefaultSelectionForegroundColor := StyleSheet colorAt:'text.selectionForegroundColor'.
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
   302
    DefaultSelectionBackgroundColor := StyleSheet colorAt:'text.selectionBackgroundColor'.
2630
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
   303
"/    DefaultAlternativeSelectionForegroundColor := StyleSheet colorAt:'text.alternativeSelectionForegroundColor' default:DefaultSelectionForegroundColor.
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
   304
"/    DefaultAlternativeSelectionBackgroundColor := StyleSheet colorAt:'text.alternativeSelectionBackgroundColor' default:DefaultSelectionBackgroundColor.
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
   305
    DefaultAlternativeSelectionForegroundColor := DefaultSelectionForegroundColor.
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
   306
    DefaultAlternativeSelectionBackgroundColor := DefaultSelectionBackgroundColor.
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   307
    DefaultFont := StyleSheet fontAt:'textView.font'.
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
   308
    MatchDelayTime := 0.6.
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
   309
    WordSelectCatchesBlanks := StyleSheet at:'text.wordSelectCatchesBlanks' default:false.
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   310
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   311
    "Modified: / 03-07-2006 / 16:29:42 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   312
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   313
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   314
!TextView class methodsFor:'help specs'!
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   315
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   316
flyByHelpSpec
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   317
    "This resource specification was automatically generated
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   318
     by the UIHelpTool of ST/X."
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   319
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   320
    "Do not manually edit this!! If it is corrupted,
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   321
     the UIHelpTool may not be able to read the specification."
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   322
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   323
    "
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   324
     UIHelpTool openOnClass:TextView
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   325
    "
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   326
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   327
    <resource: #help>
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   328
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   329
    ^ Dictionary new addPairsFrom:#(
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   330
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   331
#matchSearch
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   332
'Search for a pattern (glob) as opposed to a direct string search'
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   333
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   334
#searchCaseSensitive
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   335
'Care for case differences'
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   336
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   337
#searchFullWord
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   338
'Search only for full words (ignore occurrences as substring)'
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   339
5078
e261152d89d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5077
diff changeset
   340
#searchAtBeginOfLineOnly
e261152d89d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5077
diff changeset
   341
'Search only for the string at the beginning if a line'
e261152d89d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5077
diff changeset
   342
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   343
#searchPattern
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   344
'String or match-pattern to be searched'
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   345
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   346
#searchVariable
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   347
'Search only for that variable name (ignore occurrences in other contexts)'
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   348
4485
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   349
#replaceText
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   350
'If checked, matching text is replaced by this (everywhere)'
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   351
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   352
#selectLines
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   353
'If checked, lines containing the matched string are selected.'
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   354
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   355
)
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   356
! !
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
   357
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   358
!TextView class methodsFor:'interface specs'!
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   359
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   360
searchDialogSpec
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   361
    "This resource specification was automatically generated
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   362
     by the UIPainter of ST/X."
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   363
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   364
    "Do not manually edit this!! If it is corrupted,
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   365
     the UIPainter may not be able to read the specification."
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   366
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   367
    "
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   368
     UIPainter new openOnClass:TextView andSelector:#searchDialogSpec
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   369
    "
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   370
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   371
    <resource: #canvas>
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   372
4605
ea4d356f3f96 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4602
diff changeset
   373
    ^ 
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   374
    #(FullSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   375
       name: searchDialogSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   376
       window: 
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   377
      (WindowSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   378
         label: 'String search'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   379
         name: 'String search'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   380
         min: (Point 10 10)
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   381
         max: (Point 1280 1024)
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   382
         bounds: (Rectangle 0 0 319 266)
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   383
       )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   384
       component: 
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   385
      (SpecCollection
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   386
         collection: (
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   387
          (LabelSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   388
             label: 'SearchPattern:'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   389
             name: 'label'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   390
             layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   391
             level: 0
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   392
             translateLabel: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   393
             adjust: left
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   394
           )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   395
          (ComboBoxSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   396
             name: 'patternComboBox'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   397
             layout: (LayoutFrame 2 0.0 26 0 -2 1.0 48 0)
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   398
             activeHelpKey: searchPattern
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   399
             tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   400
             model: searchPattern
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   401
             immediateAccept: false
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   402
             acceptOnLeave: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   403
             acceptOnReturn: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   404
             acceptOnTab: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   405
             acceptOnLostFocus: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   406
             acceptOnPointerLeave: false
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   407
             autoSelectInitialText: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   408
             comboList: patternList
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   409
           )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   410
          (VerticalPanelViewSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   411
             name: 'VerticalPanel1'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   412
             layout: (LayoutFrame 0 0.0 52 0 0 1.0 -30 1)
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   413
             horizontalLayout: fit
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   414
             verticalLayout: top
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   415
             component: 
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   416
            (SpecCollection
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   417
               collection: (
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   418
                (CheckBoxSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   419
                   label: 'Case Sensitive'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   420
                   name: 'ignoreCaseCheckBox'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   421
                   activeHelpKey: searchCaseSensitive
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   422
                   level: 0
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   423
                   tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   424
                   model: caseSensitive
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   425
                   translateLabel: true
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   426
                   extent: (Point 319 24)
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   427
                 )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   428
                (CheckBoxSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   429
                   label: 'Match (forward only)'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   430
                   name: 'matchCheckBox'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   431
                   activeHelpKey: matchSearch
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   432
                   level: 0
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   433
                   tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   434
                   model: match
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   435
                   translateLabel: true
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   436
                   extent: (Point 319 24)
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   437
                 )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   438
                (CheckBoxSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   439
                   label: 'Search Full Words'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   440
                   name: 'CheckBox2'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   441
                   activeHelpKey: searchFullWord
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   442
                   level: 0
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   443
                   enableChannel: searchFullWordEnabled
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   444
                   tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   445
                   model: searchFullWord
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   446
                   translateLabel: true
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   447
                   extent: (Point 319 24)
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   448
                 )
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   449
                (CheckBoxSpec
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   450
                   label: 'At Begin of Line Only'
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   451
                   name: 'CheckBox5'
5078
e261152d89d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5077
diff changeset
   452
                   activeHelpKey: searchAtBeginOfLineOnly
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   453
                   level: 0
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   454
                   tabable: true
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   455
                   model: searchAtBeginOfLineOnly
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   456
                   translateLabel: true
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   457
                   extent: (Point 319 24)
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   458
                 )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   459
                (CheckBoxSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   460
                   label: 'Variable Only'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   461
                   name: 'CheckBox1'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   462
                   activeHelpKey: searchVariable
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   463
                   level: 0
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   464
                   visibilityChannel: searchVariableVisible
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   465
                   enableChannel: searchVariableEnabled
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   466
                   tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   467
                   model: searchVariable
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   468
                   translateLabel: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   469
                   labelChannel: stringWithVariableUnderCursorHolder
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   470
                   extent: (Point 319 24)
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   471
                 )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   472
                (CheckBoxSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   473
                   label: 'Select Lines'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   474
                   name: 'CheckBox3'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   475
                   activeHelpKey: selectLines
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   476
                   level: 0
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   477
                   initiallyInvisible: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   478
                   tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   479
                   model: selectLines
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   480
                   translateLabel: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   481
                   extent: (Point 302 24)
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   482
                 )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   483
                (ViewSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   484
                   name: 'Box1'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   485
                   component: 
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   486
                  (SpecCollection
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   487
                     collection: (
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   488
                      (CheckBoxSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   489
                         label: 'Global Replace With:'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   490
                         name: 'CheckBox4'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   491
                         layout: (LayoutFrame 0 0 0 0 162 0 23 0)
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   492
                         activeHelpKey: replaceText
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   493
                         level: 0
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   494
                         enableChannel: replaceEnabled
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   495
                         tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   496
                         model: replaceBoolean
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   497
                         translateLabel: true
4605
ea4d356f3f96 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4602
diff changeset
   498
                       )
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   499
                      (InputFieldSpec
5010
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   500
                         name: 'ReplaceEntryField'
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   501
                         layout: (LayoutFrame 164 0 0 0 -2 1 22 0)
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   502
                         activeHelpKey: replaceText
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   503
                         visibilityChannel: replaceBoolean
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   504
                         enableChannel: replaceBoolean
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   505
                         model: replaceTextHolder
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   506
                         acceptOnReturn: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   507
                         acceptOnTab: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   508
                         acceptOnPointerLeave: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   509
                       )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   510
                      )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   511
                    
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   512
                   )
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   513
                   extent: (Point 319 24)
4605
ea4d356f3f96 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4602
diff changeset
   514
                 )
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   515
                )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   516
              
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   517
             )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   518
           )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   519
          (HorizontalPanelViewSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   520
             name: 'horizontalPanelView'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   521
             layout: (LayoutFrame 0 0.0 -30 1.0 -16 1.0 0 1.0)
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   522
             level: 0
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   523
             horizontalLayout: fitSpace
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   524
             verticalLayout: center
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   525
             horizontalSpace: 3
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   526
             verticalSpace: 3
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   527
             ignoreInvisibleComponents: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   528
             reverseOrderIfOKAtLeft: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   529
             component: 
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   530
            (SpecCollection
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   531
               collection: (
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   532
                (ActionButtonSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   533
                   label: 'Cancel'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   534
                   name: 'cancelButton'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   535
                   level: 2
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   536
                   translateLabel: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   537
                   tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   538
                   model: cancel
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   539
                   extent: (Point 96 21)
4605
ea4d356f3f96 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4602
diff changeset
   540
                 )
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   541
                (ActionButtonSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   542
                   label: 'Prev'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   543
                   name: 'prevButton'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   544
                   level: 2
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   545
                   translateLabel: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   546
                   tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   547
                   model: prevAction
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   548
                   extent: (Point 97 21)
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   549
                 )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   550
                (ActionButtonSpec
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   551
                   label: 'Next'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   552
                   name: 'nextButton'
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   553
                   level: 2
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   554
                   borderWidth: 1
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   555
                   translateLabel: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   556
                   tabable: true
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   557
                   model: nextAction
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   558
                   isDefault: true
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
   559
                   extent: (Point 96 21)
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   560
                 )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   561
                )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   562
              
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   563
             )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   564
             keepSpaceForOSXResizeHandleH: true
4605
ea4d356f3f96 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4602
diff changeset
   565
           )
4767
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   566
          )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   567
        
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   568
       )
011f40f4ece3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4755
diff changeset
   569
     )
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   570
! !
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   571
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   572
!TextView class methodsFor:'startup'!
121
claus
parents: 120
diff changeset
   573
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   574
open
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   575
    "start an empty TextView"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   576
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   577
    ^ self openWith:nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   578
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   579
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   580
openModalOnModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   581
    "start a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   582
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   583
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   584
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   585
    textView := self setupForModel:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   586
    textView topView openModal.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   587
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   588
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   589
    "Created: 14.2.1997 / 15:24:12 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   590
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   591
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   592
openModalWith:aString
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   593
    "start a textView with aString as initial contents"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   594
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   595
    ^ self openModalWith:aString title:nil
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   596
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   597
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   598
     TextView openModalWith:'some text'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   599
     EditTextView openModalWith:'some text'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   600
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   601
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   602
    "Created: 14.2.1997 / 15:19:04 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   603
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   604
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   605
openModalWith:aString title:aTitle
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   606
    "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
   607
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   608
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   609
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   610
    textView := self setupWith:aString title:aTitle.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   611
    textView topView openModal.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   612
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   613
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   614
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   615
     TextView openModalWith:'some text' title:'testing'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   616
     EditTextView openModalWith:'some text' title:'testing'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   617
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   618
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   619
    "Modified: 9.9.1996 / 19:32:29 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   620
    "Created: 14.2.1997 / 15:19:18 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   621
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   622
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   623
openOn:aFileName
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   624
    "start a textView on a file; return the textView"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   625
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   626
    |textView|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   627
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   628
    textView := self setupForFile:aFileName.
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   629
    textView topView open.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   630
    ^ textView
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   631
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   632
    "
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   633
     TextView openOn:'../../doc/overview.doc'
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   634
     EditTextView openOn:'../../doc/overview.doc'
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   635
    "
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   636
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   637
    "Modified: 14.2.1997 / 15:21:51 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   638
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   639
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   640
openOnModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   641
    "start a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   642
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   643
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   644
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   645
    textView := self setupForModel:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   646
    textView topView open.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   647
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   648
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   649
    "Created: 14.2.1997 / 15:23:36 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   650
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   651
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   652
openWith:aStringOrStringCollection
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   653
    "start a textView with aStringOrStringCollection as initial contents"
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   654
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   655
    ^ self openWith:aStringOrStringCollection selected:false
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   656
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   657
    "
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   658
     TextView openWith:'some text'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   659
     EditTextView openWith:'some text'
2794
90115a2de9d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2793
diff changeset
   660
     Workspace openWith:'some text'
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   661
    "
119
claus
parents: 97
diff changeset
   662
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   663
    "Created: 10.12.1995 / 17:41:32 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   664
    "Modified: 5.3.1997 / 15:37:19 / cg"
126
claus
parents: 121
diff changeset
   665
!
claus
parents: 121
diff changeset
   666
2793
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   667
openWith:aStringOrStringCollection selected:selectedBoolean
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   668
    "start a textView with aStringOrStringCollection as initial (optionally selected) contents.
2793
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   669
     Return the textView."
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   670
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   671
    |textView|
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   672
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   673
    textView := self setupEmpty.
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   674
    textView contents:aStringOrStringCollection selected:selectedBoolean.
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   675
    textView topView open.
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   676
    ^ textView
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   677
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   678
    "
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   679
     TextView openWith:'some text' selected:true
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   680
     EditTextView openWith:'some text' selected:false
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   681
    "
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   682
!
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   683
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   684
openWith:aStringOrStringCollection title:aTitle
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   685
    "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
   686
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   687
    |textView|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   688
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   689
    textView := self setupWith:aStringOrStringCollection title:aTitle.
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   690
    textView topView open.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   691
    ^ textView
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   692
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   693
    "
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   694
     TextView openWith:'some text' title:'testing'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   695
     EditTextView openWith:'some text' title:'testing'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   696
    "
126
claus
parents: 121
diff changeset
   697
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   698
    "Created: 10.12.1995 / 17:40:02 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   699
    "Modified: 5.3.1997 / 15:37:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   700
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   701
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   702
setupEmpty
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   703
    "create a textview in a topview, with horizontal and
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   704
     vertical scrollbars - a helper for #startWith: and #startOn:"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   705
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   706
    |top frame label|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   707
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   708
    label := 'unnamed'.
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   709
    top := StandardSystemView label:label icon:self defaultIcon.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   710
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   711
    frame := HVScrollableView
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   712
		for:self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   713
		miniScrollerH:true miniScrollerV:false
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   714
		in:top.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   715
    frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   716
    ^ frame scrolledView
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   717
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   718
    "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
   719
!
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   720
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   721
setupForFile:aFileName
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   722
    "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
   723
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   724
    |textView f|
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   725
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   726
    textView := self setupEmpty.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   727
    aFileName notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   728
	textView setupForFile:aFileName.
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   729
    ].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   730
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   731
    ^ textView
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   732
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   733
    "Created: / 14-02-1997 / 15:21:43 / cg"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   734
    "Modified: / 25-10-2006 / 14:46:54 / cg"
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   735
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   736
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   737
setupForModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   738
    "setup a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   739
2793
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   740
    |textView|
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   741
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   742
    textView := self setupEmpty.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   743
    textView model:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   744
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   745
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   746
    "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
   747
!
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   748
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   749
setupWith:aStringOrStringCollection title:aTitle
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   750
    "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
   751
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   752
    |top textView|
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   753
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   754
    textView := self setupEmpty.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   755
    top := textView topView.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   756
    aTitle notNil ifTrue:[top label:aTitle].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   757
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   758
    aStringOrStringCollection notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   759
	textView contents:aStringOrStringCollection
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   760
    ].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   761
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   762
    ^ textView
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   763
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   764
    "Created: 9.9.1996 / 19:31:22 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   765
    "Modified: 5.3.1997 / 15:37:37 / cg"
119
claus
parents: 97
diff changeset
   766
! !
claus
parents: 97
diff changeset
   767
2744
cb920467a4b4 method category rename
Claus Gittinger <cg@exept.de>
parents: 2740
diff changeset
   768
!TextView methodsFor:'Compatibility-ST80'!
1584
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   769
2291
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   770
displaySelection:aBoolean
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   771
    "ST-80 compatibility: ignored here."
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   772
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   773
!
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   774
2118
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   775
editText:someText
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   776
    "ST-80 compatibility: set the edited text."
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   777
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   778
    self contents:someText
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   779
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   780
    "Created: / 5.2.2000 / 17:06:18 / cg"
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   781
!
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   782
2291
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   783
selectAndScroll
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   784
    "ST-80 compatibility: ignored here."
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   785
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   786
!
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   787
4554
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
   788
selectFrom:startPos to:endPos
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
   789
    "change the selection given two character positions."
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
   790
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
   791
    self selectFromCharacterPosition:startPos to:endPos
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
   792
!
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
   793
1584
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   794
selectionStartIndex
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   795
    "ST-80 compatibility: return the selections start character position."
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   796
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   797
    ^ self characterPositionOfSelection
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   798
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   799
    "Created: / 19.6.1998 / 00:21:44 / cg"
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   800
!
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   801
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   802
selectionStopIndex
2052
6f9798507b6c ST80 compatibility:
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   803
    "ST-80 compatibility: return the character position of
6f9798507b6c ST80 compatibility:
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   804
     the character right after the selection."
6f9798507b6c ST80 compatibility:
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   805
2109
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   806
    |idx|
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   807
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   808
    idx := self characterPositionOfSelectionEnd.
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   809
    idx == 0 ifTrue:[^ 0].
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   810
    ^ idx + 1
1584
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   811
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   812
    "Created: / 19.6.1998 / 00:22:08 / cg"
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   813
! !
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   814
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   815
!TextView methodsFor:'accessing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   816
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   817
characterEncoding:encodingArg
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
   818
    "define how the contents is encoded internally.
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   819
     This should normally never be required, as ST/X now assumes
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   820
     unicode (of which iso8859-1 is a subset) encoding.
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   821
     The possibility to change the characterEncoding is provided as
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   822
     a backward compatibility hook for programs which want to use
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   823
     another encoding internally."
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   824
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   825
    |encodingSymOrNil|
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   826
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   827
    encodingSymOrNil := encodingArg isNil
5070
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   828
                            ifTrue:[#'iso10646-1']
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   829
                            ifFalse:[encodingArg asSymbol].
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   830
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   831
    characterEncoding ~~ encodingSymOrNil ifTrue:[
5070
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   832
        "/ TODO: reencode contents if required.
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   833
        (list size ~~ 0
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   834
        and:[ list contains:[:line | line size > 0]]) ifTrue:[
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   835
            (self confirm:(resources stringWithCRs:'Your text may need to be re-coded - this is not yet supported.\\Proceed ?'))
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   836
            ifFalse:[^ self].
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   837
        ].
897edc4879ed class: TextView
Claus Gittinger <cg@exept.de>
parents: 5052
diff changeset
   838
        characterEncoding := encodingSymOrNil.
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   839
    ].
4361
646cd7c5513e comment/format in: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents: 4321
diff changeset
   840
646cd7c5513e comment/format in: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents: 4321
diff changeset
   841
    "Modified (format): / 25-01-2012 / 00:28:27 / cg"
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
   842
!
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
   843
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   844
characterPositionOfSelection
1303
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   845
    "return the character index of the first character in the selection.
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   846
     Returns 0 if there is no selection."
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   847
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   848
    selectionStartLine isNil ifTrue:[^ 0].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   849
    ^ self characterPositionOfLine:selectionStartLine
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   850
			       col:selectionStartCol
1303
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   851
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   852
    "Modified: 14.8.1997 / 16:35:37 / cg"
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   853
!
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   854
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   855
characterPositionOfSelectionEnd
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   856
    "return the character index of the last character in the selection.
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   857
     Returns 0 if there is no selection."
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   858
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   859
    selectionStartLine isNil ifTrue:[^ 0].
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   860
    ^ self characterPositionOfLine:selectionEndLine
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   861
			       col:selectionEndCol
1303
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   862
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   863
    "Created: 14.8.1997 / 16:35:24 / cg"
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   864
    "Modified: 14.8.1997 / 16:35:45 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   865
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   866
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   867
contentsWasSaved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   868
    "return true, if the contents was saved (by a save action),
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   869
     false if not (or was modified again after the last save)."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   870
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   871
    ^ contentsWasSaved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   872
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   873
3214
7ab9bba4883d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3212
diff changeset
   874
contentsWasSaved:aBoolean
7ab9bba4883d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3212
diff changeset
   875
    contentsWasSaved := aBoolean
7ab9bba4883d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3212
diff changeset
   876
!
7ab9bba4883d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3212
diff changeset
   877
3212
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   878
defaultFileNameForFileDialog
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   879
    "return the default fileName to use for the save-box"
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   880
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   881
    ^ defaultFileNameForFileDialog
3212
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   882
!
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   883
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   884
defaultFileNameForFileDialog:aBaseName
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   885
    "define the default fileName to use for the save-box"
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   886
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   887
    defaultFileNameForFileDialog := aBaseName
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   888
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   889
    "Created: 13.2.1997 / 18:29:53 / cg"
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   890
!
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   891
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   892
directoryForFileDialog:aDirectory
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   893
    "define the default directory to use for save-box"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   894
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   895
    directoryForFileDialog := aDirectory
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   896
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   897
    "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
   898
!
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   899
2941
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   900
externalEncoding
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   901
    "return the encoding used when the contents is saved via the 'save / save as' dialog.
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   902
     This is (currently only) passed down from the fileBrowser,
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   903
     and required when  utf8/japanese/chinese/korean text is edited.
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   904
     (encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc).
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   905
     Notice: this only affects the external representation of the text."
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   906
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   907
    ^ externalEncoding
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   908
!
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   909
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   910
externalEncoding:encodingSymOrNil
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   911
    "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
   912
     via the 'save / save as' dialog.
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   913
     This is (currently only) passed down from the fileBrowser,
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   914
     and required when  utf8/japanese/chinese/korean text is edited.
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   915
     (encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc).
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   916
     Notice: this only affects the external representation of the text."
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   917
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   918
    externalEncoding := encodingSymOrNil
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   919
!
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   920
2581
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   921
parenthesisSpecification
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   922
    "return the value of the instance variable 'parenthesisSpecification' (automatically generated)"
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   923
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   924
    ^ parenthesisSpecification
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   925
!
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   926
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   927
parenthesisSpecification:aDictionary
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   928
    "set the dictionary which specifies which characters are opening, which are closing
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   929
     and which are ignored characters w.r.t. parenthesis matching.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   930
     See the classes initialize method for a useful value."
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   931
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   932
    parenthesisSpecification := aDictionary
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
   933
!
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
   934
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
   935
saveAction:something
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
   936
    saveAction := something.
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
   937
!
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
   938
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
   939
searchBarActionBlock
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
   940
    ^ searchBarActionBlock
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
   941
!
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
   942
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
   943
searchBarActionBlock:something
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
   944
    searchBarActionBlock := something.
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   945
! !
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   946
3787
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   947
!TextView methodsFor:'accessing-behavior'!
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   948
4485
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   949
isReadOnly
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   950
    ^ true
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   951
!
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   952
3787
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   953
readOnly:aBoolean
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   954
    "for protocol compatibility with editTextViews,
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   955
     but actually ignored"
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   956
! !
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   957
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   958
!TextView methodsFor:'accessing-contents'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   959
2791
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   960
contents:newContents selected:selectedBoolean
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   961
    self contents:newContents.
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   962
    selectedBoolean ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   963
	list size == 1 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   964
	    self selectFromLine:1 col:1 toLine:1 col:(list at:1) size
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   965
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   966
	    self selectAll
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
   967
	]
2791
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   968
    ]
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   969
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   970
    "
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   971
     |w|
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   972
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   973
     w := Workspace new open.
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   974
     w contents:'Hello world' selected:true.
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   975
    "
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   976
!
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   977
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   978
fromFile:aFileName
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   979
    "take contents from a named file"
3724
5db1580f82ba mark obsolete message
Stefan Vogel <sv@exept.de>
parents: 3708
diff changeset
   980
    <resource: #obsolete>
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   981
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   982
    self obsoleteMethodWarning.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   983
    ^ self loadTextFile:aFileName.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   984
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   985
    "Modified: / 25-10-2006 / 14:47:35 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   986
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   987
4755
d47ae92cc09f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4748
diff changeset
   988
list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw
d47ae92cc09f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4748
diff changeset
   989
    "set the displayed contents (a collection of strings) with redraw.
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   990
     Redefined since changing the contents implies deselect"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   991
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   992
    self unselect.
4755
d47ae92cc09f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4748
diff changeset
   993
    super list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   994
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   995
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   996
loadTextFile:aFileName
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   997
    "take contents from a named file"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   998
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   999
    |f|
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1000
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1001
    f := aFileName asFilename.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1002
    self directoryForFileDialog:(f directoryName).
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1003
    self contents:(f contents)
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1004
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1005
    "Created: / 25-10-2006 / 14:44:01 / cg"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1006
!
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1007
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1008
setContents:something
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1009
    "set the contents (either a string or a Collection of strings)
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1010
     dont change the position (i.e. do not scroll) or the selection."
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1011
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1012
    |selStartLine selStartCol selEndLine selEndCol selStyle|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1013
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1014
    selStartLine := selectionStartLine.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1015
    selStartCol := selectionStartCol.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1016
    selEndLine := selectionEndLine.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1017
    selEndCol := selectionEndCol.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1018
    selStyle := selectStyle.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1019
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1020
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1021
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1022
    selStartLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1023
	self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1024
	    selectFromLine:selStartLine col:selStartCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1025
	    toLine:selEndLine col:selEndCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1026
	selectStyle := selStyle
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1027
    ].
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1028
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1029
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1030
    "Modified: / 31.3.1998 / 23:33:21 / cg"
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1031
!
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1032
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1033
setList:something
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1034
    "set the displayed contents (a collection of strings)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1035
     without redraw.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1036
     Redefined since changing contents implies deselect"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1037
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1038
    self unselect.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1039
    super setList:something
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1040
!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1041
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1042
setupForFile:aFileName
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1043
    "take contents from a named file"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1044
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1045
    |baseName|
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1046
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1047
    self loadTextFile:aFileName.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1048
    aFileName notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1049
	baseName := aFileName asFilename baseName.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1050
	self topView label:baseName.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1051
	self defaultFileNameForFileDialog:baseName.
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1052
    ].
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1053
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1054
    "Created: / 25-10-2006 / 14:47:13 / cg"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1055
!
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
  1056
1487
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
  1057
text
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
  1058
    "for ST80 compatibility"
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
  1059
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
  1060
    ^ self contents
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
  1061
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
  1062
    "Created: / 19.4.1998 / 12:53:10 / cg"
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
  1063
!
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
  1064
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1065
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
  1066
    "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
  1067
     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
  1068
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1069
    |beginCol endCol endLine thisCharacter flag|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1070
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1071
    flag := #word.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1072
    beginCol := selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1073
    endCol := selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1074
    endLine := selectLine.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1075
    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
  1076
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1077
    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
  1078
    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
  1079
    endCol == 0 ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1080
	endLine := selectLine + 1
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1081
    ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1082
1750
d87cc464fde2 comment
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
  1083
    "is the initial character within a word ?"
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1084
    (wordCheck value:thisCharacter) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1085
	"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1086
	 try to catch a blank ...
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1087
	"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1088
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1089
	WordSelectCatchesBlanks ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1090
	    ((beginCol == 1)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1091
	    or:[(self characterAtLine:selectLine col:(beginCol - 1))
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1092
		 ~~ Character space]) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1093
		((self characterAtLine:selectLine col:(endCol + 1))
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1094
		  == Character space) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1095
		    endCol := endCol + 1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1096
		    flag := #wordRight
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1097
		]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1098
	    ] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1099
		beginCol := beginCol - 1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1100
		flag := #wordLeft
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1101
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1102
	].
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1103
    ].
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1104
    aFiveArgBlock value:selectLine
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1105
		  value:beginCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1106
		  value:endLine
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1107
		  value:endCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1108
		  value:flag
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1109
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1110
    "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
  1111
! !
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1112
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1113
!TextView methodsFor:'accessing-look'!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1114
2027
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1115
selectionBackgroundColor
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1116
    "return the selection-background color."
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1117
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1118
    ^ selectionBgColor
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1119
!
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1120
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1121
selectionForegroundColor
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1122
    "return the selection-foreground color."
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1123
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1124
    ^ selectionFgColor
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1125
!
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
  1126
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1127
selectionForegroundColor:color1 backgroundColor:color2
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1128
    "set both the selection-foreground and cursor background colors.
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1129
     The default is defined by the styleSheet;
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1130
     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
  1131
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1132
    selectionFgColor := color1 onDevice:device.
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1133
    selectionBgColor := color2 onDevice:device.
2913
bdf4fb09cfc0 invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
  1134
    self hasSelection ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1135
	self invalidate
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1136
    ]
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1137
722
3f297a438fec use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1138
    "Modified: 29.5.1996 / 16:22:15 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1139
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1140
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1141
!TextView methodsFor:'accessing-mvc'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1142
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1143
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
  1144
    "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
  1145
     and selection. Added for ST-80 compatibility"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1146
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1147
    aspectSym notNil ifTrue:[aspectMsg := aspectSym.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1148
			     listMsg isNil ifTrue:[listMsg := aspectSym]].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1149
    changeSym notNil ifTrue:[changeMsg := changeSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1150
    listSym notNil ifTrue:[listMsg := listSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1151
    menuSym notNil ifTrue:[menuMsg := menuSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1152
"/    initial notNil ifTrue:[initialSelectionMsg := initial].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1153
    self model:aModel.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1154
824
f62922fcfa5d Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  1155
    "Modified: 15.8.1996 / 12:52:54 / stefan"
906
a8b9b481ce70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1156
    "Modified: 2.1.1997 / 16:11:28 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1157
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1158
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1159
!TextView methodsFor:'drag & drop'!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1160
96256221e3af support drag
ca
parents: 2581
diff changeset
  1161
allowDrag:aBoolean
96256221e3af support drag
ca
parents: 2581
diff changeset
  1162
    "enable/disable dragging support
96256221e3af support drag
ca
parents: 2581
diff changeset
  1163
    "
96256221e3af support drag
ca
parents: 2581
diff changeset
  1164
    aBoolean ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1165
	dropSource := nil.
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1166
    ] ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1167
	dropSource isNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1168
	    dropSource := DropSource
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1169
			    receiver:self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1170
			    argument:nil
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1171
			    dropObjectSelector:#collectionOfDragObjects
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1172
			    displayObjectSelector:nil
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1173
	]
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1174
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  1175
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1176
96256221e3af support drag
ca
parents: 2581
diff changeset
  1177
canDrag
4368
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  1178
    "returns true if dragging is enabled"
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  1179
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  1180
    ^ dropSource notNil and:[ self hasSelection ]
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  1181
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  1182
    "Modified (comment): / 12-02-2012 / 08:37:21 / cg"
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1183
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1184
96256221e3af support drag
ca
parents: 2581
diff changeset
  1185
collectionOfDragObjects
96256221e3af support drag
ca
parents: 2581
diff changeset
  1186
    "returns collection of dragable objects assigned to selection
96256221e3af support drag
ca
parents: 2581
diff changeset
  1187
     Here, by default, a collection of text-dragObjects is generated;
96256221e3af support drag
ca
parents: 2581
diff changeset
  1188
     however, if a dragObjectConverter is defined, that one gets a chance
96256221e3af support drag
ca
parents: 2581
diff changeset
  1189
     to convert as appropriate.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1190
    "
96256221e3af support drag
ca
parents: 2581
diff changeset
  1191
    |selection|
96256221e3af support drag
ca
parents: 2581
diff changeset
  1192
96256221e3af support drag
ca
parents: 2581
diff changeset
  1193
    selection := self selection.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1194
96256221e3af support drag
ca
parents: 2581
diff changeset
  1195
    selection size == 0 ifTrue:[^ nil].
96256221e3af support drag
ca
parents: 2581
diff changeset
  1196
  ^ Array with:(DropObject newText:selection).
96256221e3af support drag
ca
parents: 2581
diff changeset
  1197
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1198
96256221e3af support drag
ca
parents: 2581
diff changeset
  1199
dropSource
3245
b17c15b61e94 ugly comments
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1200
    "returns the dropSource or nil"
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1201
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1202
    ^ dropSource
96256221e3af support drag
ca
parents: 2581
diff changeset
  1203
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1204
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1205
dropSource:aDropSourceOrNil
3245
b17c15b61e94 ugly comments
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1206
    "set the dropSource or nil"
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1207
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1208
    dropSource := aDropSourceOrNil.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1209
! !
96256221e3af support drag
ca
parents: 2581
diff changeset
  1210
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1211
!TextView methodsFor:'encoding'!
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1212
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1213
validateFontEncodingFor:newEncoding ask:ask
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1214
    "if required, query user if he/she wants to change to another font,
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1215
     which is able to display text encoded as specified by newEncoding"
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1216
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1217
    |fontsEncoding msg filter f defaultFont pref matchingFonts
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1218
     matchingFamilyFonts matchingFamilyFaceFonts matchingFamilyFaceStyleFonts
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1219
     matchingFamilyFaceStyleSizeFonts|
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1220
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1221
    fontsEncoding := font encoding.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1222
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1223
    pref := FontDescription preferredFontEncodingFor:newEncoding.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1224
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1225
    (pref match:fontsEncoding) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1226
	^ self
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1227
    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1228
    (CharacterEncoder isEncoding:pref subSetOf:fontsEncoding) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1229
	^ self
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1230
    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1231
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1232
    filter := [:f | |coding|
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1233
		    (coding := f encoding) notNil
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1234
		    and:[pref match:coding]].
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1235
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1236
    device flushListOfAvailableFonts.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1237
    matchingFonts := device listOfAvailableFonts select:filter.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1238
    matchingFamilyFonts := matchingFonts select:[:f | f family = font family].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1239
    matchingFamilyFaceFonts := matchingFamilyFonts select:[:f | f face = font face].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1240
    matchingFamilyFaceStyleFonts := matchingFamilyFaceFonts select:[:f | f style = font style].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1241
    matchingFamilyFaceStyleSizeFonts := matchingFamilyFaceStyleFonts select:[:f | f size = font size].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1242
    matchingFamilyFaceStyleSizeFonts size > 0 ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1243
	defaultFont := matchingFamilyFaceStyleSizeFonts first
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1244
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1245
	matchingFamilyFaceStyleFonts size > 0 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1246
	    defaultFont := matchingFamilyFaceStyleFonts first
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1247
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1248
	    matchingFamilyFaceFonts size > 0 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1249
		defaultFont := matchingFamilyFaceFonts first
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1250
	    ] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1251
		matchingFamilyFonts size > 0 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1252
		    defaultFont := matchingFamilyFonts first
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1253
		] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1254
		    matchingFonts size > 0 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1255
			defaultFont := matchingFonts first
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1256
		    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1257
		].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1258
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1259
	].
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1260
    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1261
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1262
    defaultFont isNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1263
	defaultFont isNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1264
	    self warn:'Your display does not seem to provide any ' , newEncoding allBold , ' encoded font.\\Please select an appropriate font (iso10646-Unicode recommended)'.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1265
	    pref := #'iso10646-1'.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1266
	]
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1267
    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1268
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
  1269
    msg := 'Switch to a %1 encoded font ?'.
3189
945a221e5cb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3045
diff changeset
  1270
    (ask not or:[self confirm:(resources stringWithCRs:msg with:pref)])
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1271
    ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1272
	self withWaitCursorDo:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1273
	    f := FontPanel
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1274
		    fontFromUserInitial:defaultFont
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1275
		    title:(resources string:'Font selection')
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1276
		    filter:filter
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1277
		    encoding:pref.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1278
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1279
	    f notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1280
		self font:f.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1281
	    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1282
	]
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1283
    ]
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1284
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1285
    "Created: 26.10.1996 / 12:06:54 / cg"
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1286
    "Modified: 30.6.1997 / 17:46:46 / cg"
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1287
! !
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1288
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  1289
!TextView methodsFor:'event handling'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1290
3040
f5e9092f3312 buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents: 3001
diff changeset
  1291
buttonMotion:buttonState x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1292
    "mouse-move while button was pressed - handle selection changes"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1293
3219
e8c7679a8a94 buttonrelease behavior, when released in another view
Claus Gittinger <cg@exept.de>
parents: 3214
diff changeset
  1294
    (clickLine isNil or:[clickPos isNil]) ifTrue:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1295
        dragIsActive := false.
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1296
        ^ self
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1297
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  1298
96256221e3af support drag
ca
parents: 2581
diff changeset
  1299
    dragIsActive ifTrue:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1300
        (clickPos dist:(x@y)) >= 5.0 ifTrue:[
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1301
            dragIsActive := false.
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1302
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1303
            self hasSelection ifTrue:[
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1304
                dropSource startDragIn:self at:(x@y)
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1305
            ]
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1306
        ].
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1307
        ^ self
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1308
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1309
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
  1310
    "is it the select or 1-button ?"
3040
f5e9092f3312 buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents: 3001
diff changeset
  1311
    buttonState == 0 ifTrue:[^ self].
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1312
    self sensor leftButtonPressed ifFalse:[
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1313
        "/ self setPrimarySelection.
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1314
        "/ self selectionChanged.
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1315
        ^ self
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1316
    ].
3040
f5e9092f3312 buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents: 3001
diff changeset
  1317
"/    (device buttonMotionMask:buttonState includesButton:#select) ifFalse:[
f5e9092f3312 buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents: 3001
diff changeset
  1318
"/        (device buttonMotionMask:buttonState includesButton:1) ifFalse:[
1619
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1319
"/            ^ self
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1320
"/        ].
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1321
"/    ].
53
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
  1322
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1323
    "if moved outside of view, start autoscroll"
3202
8217b0acc9f2 select from beginning (in editField
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
  1324
4160
a9c329c2784d changed: buttonMotion:x:y:
Claus Gittinger <cg@exept.de>
parents: 4156
diff changeset
  1325
    ((y < 0) and:[firstLineShown ~~ 0]) ifTrue:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1326
        self compressMotionEvents:false.
5094
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1327
        (self startAutoScrollUp:y negated) ifTrue:[
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1328
            ^ self
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1329
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1330
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1331
    (y > height) ifTrue:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1332
        self compressMotionEvents:false.
5094
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1333
        (self startAutoScrollDown:(y - height)) ifTrue:[ 
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1334
            ^ self
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1335
        ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1336
    ].
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  1337
    ((x < 0) and:[viewOrigin x ~~ 0]) ifTrue:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1338
        self compressMotionEvents:false.
5094
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1339
        (self startAutoScrollLeft:x) ifTrue:[
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1340
            ^ self
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1341
        ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1342
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1343
    (x > width) ifTrue:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1344
        self compressMotionEvents:false.
5094
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1345
        (self startAutoScrollRight:(x - width)) ifTrue:[
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1346
            ^ self
520a8c202db3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5093
diff changeset
  1347
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1348
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1349
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1350
    "move inside - stop autoscroll if any"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1351
    autoScrollBlock notNil ifTrue:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1352
        self stopScrollSelect
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1353
    ].
3220
246c5a3bfefa oops - leftover prints
Claus Gittinger <cg@exept.de>
parents: 3219
diff changeset
  1354
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1355
    self extendSelectionToX:x y:y setPrimarySelection:false.
1619
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1356
4160
a9c329c2784d changed: buttonMotion:x:y:
Claus Gittinger <cg@exept.de>
parents: 4156
diff changeset
  1357
    "Modified: / 08-08-2010 / 11:20:54 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1358
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1359
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1360
buttonMultiPress:button x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1361
    "multi-mouse-click - select word under pointer"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1362
3914
ceb85ec53629 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3909
diff changeset
  1363
    (button == 1) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1364
	clickPos := x @ y.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1365
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1366
	"/ The searchAction is mantained until a cut/replace or a search with a user selection is done
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  1367
"/        self clearSearchAction.
2814
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1368
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1369
	clickCount notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1370
	    clickCount := clickCount + 1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1371
	    (clickCount == 2) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1372
		self doubleClickX:x y:y
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1373
	    ] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1374
		(clickCount == 3) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1375
		    self tripleClickX:x y:y
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1376
		] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1377
		    (clickCount == 4) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1378
			self quadClickX:x y:y
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1379
		    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1380
		]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1381
	    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1382
	]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1383
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1384
	super buttonMultiPress:button x:x y:y
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1385
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1386
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1387
    "Modified: 11.9.1997 / 04:15:35 / cg"
248
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
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1390
buttonPress:button x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1391
    "mouse-click - prepare for selection change"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1392
1308
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1393
    |sensor clickVisibleLine|
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1394
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1395
    dragIsActive := false.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1396
    sensor       := self sensor.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1397
3914
ceb85ec53629 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3909
diff changeset
  1398
    (button == 1) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1399
	sensor shiftDown ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1400
	    "mouse-click with shift - adding to selection"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1401
	    self extendSelectionToX:x y:y.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1402
	    ^ self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1403
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1404
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1405
	clickVisibleLine := self visibleLineOfY:y.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1406
	clickPos := x @ y.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1407
	clickCol := self colOfX:x inVisibleLine:clickVisibleLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1408
	clickLine := self visibleLineToAbsoluteLine:clickVisibleLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1409
	clickStartLine := clickLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1410
	clickStartCol := clickCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1411
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1412
	(self canDrag
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1413
	and:[(self isInSelection:clickLine col:clickCol)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1414
	and:[UserPreferences current startTextDragWithControl not
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1415
	     or:[sensor ctrlDown]]]) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1416
	    dragIsActive := true
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1417
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1418
	    self unselect.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1419
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1420
	clickCount := 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1421
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1422
	super buttonPress:button x:x y:y
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1423
    ]
813
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  1424
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1425
    "Modified: / 20.5.1999 / 17:02:45 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1426
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1427
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1428
buttonRelease:button x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1429
    "mouse- button release - turn off autoScroll if any"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1430
3914
ceb85ec53629 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3909
diff changeset
  1431
    (button == 1) ifTrue:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1432
        self hasSelection ifTrue:[
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1433
            self setPrimarySelection.
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1434
            self selectionChanged.
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1435
        ].
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1436
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1437
        autoScrollBlock notNil ifTrue:[
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1438
            self stopScrollSelect
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1439
        ].
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1440
        dragIsActive ifTrue:[
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1441
            self unselect
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1442
        ].
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1443
        clickPos := nil.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1444
    ] ifFalse:[
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1445
        super buttonRelease:button x:x y:y
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1446
    ].
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1447
    dragIsActive := false.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1448
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1449
    "/ clickPos := clickLine := clickCol := nil.
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1450
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1451
    "Modified: / 20.5.1999 / 17:14:23 / cg"
824
f62922fcfa5d Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  1452
!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1453
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1454
doubleClickX:x y:y
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1455
    "double-click - select word under pointer"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1456
3588
a70267e5b501 st80 behavior: also scan for matching single quote
Claus Gittinger <cg@exept.de>
parents: 3587
diff changeset
  1457
    |sel ch scanCh matchCol scanCol fwdScan fwdSelect|
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1458
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1459
    self selectWordAtX:x y:y.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1460
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1461
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1462
     special - if clicked on a parenthesis, select to matching
4702
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1463
     (must de before doing the ST80 stuff below)
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1464
    "
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1465
    ((sel := self selection) size == 1
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1466
    and:[(sel := sel at:1) size == 1]) ifTrue:[
4702
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1467
        ch := sel at:1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1468
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1469
        ((self isOpeningParenthesis:ch)
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1470
        or:[ (self isClosingParenthesis:ch) ]) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1471
            self
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1472
                searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1473
                ifFound:[:line :col |
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1474
                              |prevLine prevCol moveBack pos1|
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1475
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1476
                              prevLine := firstLineShown.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1477
                              prevCol := viewOrigin x.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1478
                              self selectFromLine:selectionStartLine col:selectionStartCol
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1479
                                           toLine:line col:col.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1480
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1481
                              self sensor ctrlDown ifFalse:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1482
                                  "/ undo scroll operation ...
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1483
                                  self withCursor:Cursor eye do:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1484
                                      |delayCount|
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1485
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1486
                                      moveBack := false.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1487
                                      (self isClosingParenthesis:ch) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1488
                                           (firstLineShown ~~ prevLine or:[prevCol ~~ viewOrigin x]) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1489
                                               moveBack := true
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1490
                                           ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1491
                                      ] ifFalse:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1492
                                           selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1493
                                               self makeLineVisible:selectionEndLine.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1494
                                               moveBack := true
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1495
                                           ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1496
                                      ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1497
                                      moveBack ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1498
                                           delayCount  := 0.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1499
                                           pos1 := x@y.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1500
                                           self invalidateRepairNow:true.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1501
                                           Delay waitForSeconds:MatchDelayTime.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1502
                                           delayCount := delayCount + MatchDelayTime.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1503
                                           [self sensor hasUserEventFor:self] whileFalse:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1504
                                                Delay waitForSeconds:MatchDelayTime / 2.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1505
                                                delayCount := delayCount + (MatchDelayTime / 2).
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1506
                                                delayCount > 2 ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1507
                                                    self cursor:Cursor eyeClosed.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1508
                                                ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1509
                                                delayCount >= 2.3 ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1510
                                                    self cursor:Cursor eye.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1511
                                                    delayCount := 0.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1512
                                                ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1513
                                           ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1514
                                           self scrollToLine:prevLine; scrollToCol:prevCol.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1515
                                      ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1516
                                  ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1517
                              ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1518
                              ^ self.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1519
                          ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1520
                ifNotFound:[self showNotFound]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1521
                onError:[self beep]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1522
                openingCharacters:((parenthesisSpecification at:#open) ", '([{'")
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1523
                closingCharacters:((parenthesisSpecification at:#close) ", ')]}'").
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1524
            selectStyle := nil
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1525
        ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1526
    ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1527
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1528
    (self st80SelectMode or:[ self sensor ctrlDown]) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1529
        "/ st80 selects:
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1530
        "/   - if clicked right after a parenthesis -> select to matching parenthesis
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1531
        "/   - if clicked right after a quote -> select to matching quote (unless escaped ;-)
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1532
        "/   - if clicked at beginning of the line  -> select that line
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1533
        "/   - if clicked at the top of the text    -> select all
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1534
        "/ however, do none of the above, if clicked on a parenthesis
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1535
        clickCol == 1 ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1536
            clickLine == 1 ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1537
                self selectAll.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1538
                ^ self.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1539
            ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1540
            self selectLineAtY:y.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1541
            selectStyle := #line.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1542
            ^ self
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1543
        ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1544
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1545
        matchCol := nil.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1546
        "/ see what is to the left of that character ...
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1547
        clickCol > 1 ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1548
            ch := self characterAtLine:clickLine col:clickCol-1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1549
            (self isOpeningParenthesis:ch) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1550
                matchCol := clickCol - 1
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1551
            ] ifFalse:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1552
                ('"''|' includes:ch) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1553
                    scanCol := clickCol - 1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1554
                    fwdScan := true.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1555
                    scanCh := ch.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1556
                ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1557
            ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1558
        ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1559
        fwdSelect := true.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1560
        (matchCol isNil and:[scanCol isNil]) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1561
            clickCol < (self listAt:clickLine) size ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1562
                ch := self characterAtLine:clickLine col:clickCol+1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1563
                (self isClosingParenthesis:ch) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1564
                    matchCol := clickCol + 1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1565
                    fwdSelect := false.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1566
                ] ifFalse:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1567
                    ('"''|' includes:ch) ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1568
                        scanCol := clickCol + 1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1569
                        fwdScan := false.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1570
                        scanCh := ch.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1571
                    ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1572
                ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1573
            ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1574
        ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1575
        matchCol notNil ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1576
            self
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1577
                searchForMatchingParenthesisFromLine:clickLine col:matchCol
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1578
                ifFound:[:line :col |
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1579
                          self selectFromLine:clickLine col:matchCol+(fwdSelect ifTrue:1 ifFalse:-1)
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1580
                                       toLine:line col:col-(fwdSelect ifTrue:1 ifFalse:-1)]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1581
                ifNotFound:[self showNotFound]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1582
                onError:[self beep]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1583
                openingCharacters:((parenthesisSpecification at:#open) , '([{')
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1584
                closingCharacters:((parenthesisSpecification at:#close) , ')]}').
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1585
            ^ self
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1586
        ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1587
        scanCol notNil ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1588
            "/ if its an EOL comment, do it differently
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1589
            ch := self characterAtLine:clickLine col:clickCol.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1590
            ch == $/ ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1591
                self selectFromLine:clickLine col:clickCol+1 toLine:clickLine+1 col:0.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1592
                ^ self
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1593
            ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1594
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1595
            self
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1596
                scanFor:scanCh fromLine:clickLine col:scanCol forward:fwdScan
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1597
                ifFound:[:line :col |
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1598
                            |selStart selEnd|
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1599
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1600
                            fwdScan ifTrue:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1601
                                selStart := scanCol+1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1602
                                selEnd := col-1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1603
                            ] ifFalse:[
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1604
                                selStart := scanCol-1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1605
                                selEnd := col+1.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1606
                            ].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1607
                            self selectFromLine:clickLine col:selStart
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1608
                                 toLine:line col:selEnd.
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1609
                            ^ self
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1610
                           ]
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1611
                ifNotFound:[self showNotFound].
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1612
            ^ self
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1613
        ]
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1614
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1615
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1616
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1617
     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
  1618
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1619
    wordStartLine := selectionStartLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1620
    wordEndLine := selectionEndLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1621
    selectStyle == #wordLeft ifTrue:[
4702
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1622
        wordStartCol := selectionStartCol + 1
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1623
    ] ifFalse:[
4702
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1624
        wordStartCol := selectionStartCol.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1625
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1626
    selectStyle == #wordRight ifTrue:[
4702
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1627
        wordEndCol := selectionEndCol - 1
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1628
    ] ifFalse:[
4702
02d7770b3206 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  1629
        wordEndCol := selectionEndCol
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1630
    ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1631
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  1632
    "Created: / 11-09-1997 / 04:12:55 / cg"
4255
9bf0cc2595a9 changed: #doubleClickX:y:
Claus Gittinger <cg@exept.de>
parents: 4254
diff changeset
  1633
    "Modified: / 14-06-2011 / 14:04:59 / cg"
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1634
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1635
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1636
extendSelectionToX:x y:y
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1637
    "mouse-move while button was pressed - handle selection changes"
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1638
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1639
    self extendSelectionToX:x y:y setPrimarySelection:true
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1640
!
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1641
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1642
extendSelectionToX:x y:y setPrimarySelection:aBoolean
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1643
    "mouse-move while button was pressed - handle selection changes"
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1644
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1645
    |movedVisibleLine movedLine movedCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1646
     movedUp
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1647
     oldStartLine oldEndLine oldStartCol oldEndCol|
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1648
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1649
    movedVisibleLine := self visibleLineOfY:y.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1650
    movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1651
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1652
    (x < leftMargin) ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1653
        movedCol := 0
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1654
    ] ifFalse:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1655
        movedCol := self colOfX:x inVisibleLine:movedVisibleLine
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1656
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1657
    y < 0 ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1658
        movedCol := 0
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1659
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1660
    ((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1661
        selectionStartLine notNil ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1662
            ^ self
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1663
        ].
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1664
        (clickPos isNil
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1665
        or:[(clickPos x - x) abs < 3
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1666
            and:[(clickPos y - y) abs < 3]]) ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1667
            ^ self
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1668
        ].
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1669
        selectionStartLine := clickLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1670
        selectionStartCol := clickCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1671
        selectionEndLine := selectionStartLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1672
        selectionEndCol := selectionStartCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1673
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1674
        oldStartLine := selectionStartLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1675
        oldEndLine := selectionEndLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1676
        oldStartCol := selectionStartCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1677
        oldEndCol := selectionEndCol-1.
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1678
    ] ifFalse:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1679
        selectionStartLine isNil ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1680
            selectionStartLine := selectionEndLine := clickLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1681
            selectionStartCol := selectionEndCol := clickCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1682
        ].
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1683
        oldStartLine := selectionStartLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1684
        oldEndLine := selectionEndLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1685
        oldStartCol := selectionStartCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1686
        oldEndCol := selectionEndCol.
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1687
    ].
3692
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1688
    oldEndLine isNil ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1689
        oldEndLine := selectionEndLine ? clickLine ? movedLine.
3692
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1690
    ].
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1691
    oldEndCol isNil ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1692
        oldEndCol := selectionEndCol ? clickCol.
3692
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1693
    ].
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1694
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1695
    "find out if we are before or after initial click"
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1696
    movedUp := false.
3443
09a7671630a9 changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3438
diff changeset
  1697
    clickStartLine isNil ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1698
        clickStartLine := movedLine.
3443
09a7671630a9 changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3438
diff changeset
  1699
    ].
3505
cdb364dede3e extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3496
diff changeset
  1700
    clickStartCol isNil ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1701
        clickStartCol := movedCol.
3505
cdb364dede3e extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3496
diff changeset
  1702
    ].
3443
09a7671630a9 changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3438
diff changeset
  1703
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1704
    (movedLine < clickStartLine) ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1705
        movedUp := true
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1706
    ] ifFalse:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1707
        (movedLine == clickStartLine) ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1708
            (movedCol < clickStartCol) ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1709
                movedUp := true
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1710
            ]
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1711
        ]
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1712
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1713
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1714
    movedUp ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1715
        "change selectionStart"
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1716
        selectionStartCol := movedCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1717
        selectionStartLine := movedLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1718
        selectionEndCol := clickStartCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1719
        selectionEndLine := clickStartLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1720
        selectStyle notNil ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1721
            selectionEndCol := wordEndCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1722
            selectionEndLine := wordEndLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1723
        ]
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1724
    ] ifFalse:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1725
        "change selectionEnd"
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1726
        selectionEndCol := movedCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1727
        selectionEndLine := movedLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1728
        selectionStartCol := clickStartCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1729
        selectionStartLine := clickStartLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1730
        selectStyle notNil ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1731
            selectionStartCol := wordStartCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1732
            selectionStartLine := wordStartLine.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1733
        ]
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1734
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1735
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1736
    selectionStartLine isNil ifTrue:[^ self].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1737
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1738
    (selectionStartCol == 0) ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1739
        selectionStartCol := 1
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1740
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1741
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1742
    "
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1743
     if in word-select, just catch the rest of the word
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1744
    "
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1745
    (selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1746
        movedUp ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1747
            selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1748
        ] ifFalse:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1749
            selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1750
            selectionEndCol == 0 ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1751
                selectionEndLine := selectionEndLine + 1
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1752
            ]
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1753
        ].
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1754
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1755
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1756
    selectStyle == #line ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1757
        movedUp ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1758
            selectionStartCol := 1.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1759
        ] ifFalse:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1760
            selectionEndCol := 0.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1761
            selectionEndLine := selectionEndLine + 1
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1762
        ]
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1763
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1764
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1765
    self validateNewSelection.
4885
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1766
    aBoolean ifTrue:[
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1767
        self setPrimarySelection.
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1768
        self selectionChanged.
c2cd790c43d3 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4864
diff changeset
  1769
    ].
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1770
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  1771
    "/ The searchAction is mantained until a cut/replace or a search with a user selection is done
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  1772
"/    self clearSearchAction.
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1773
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1774
    (oldStartLine == selectionStartLine) ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1775
        (oldStartCol ~~ selectionStartCol) ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1776
            self 
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1777
                redrawLine:oldStartLine
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1778
                      from:((selectionStartCol min:oldStartCol) max:1)
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1779
                        to:((selectionStartCol max:oldStartCol) max:1)
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1780
        ]
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1781
    ] ifFalse:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1782
        self 
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1783
            redrawFromLine:(oldStartLine?selectionStartLine min:selectionStartLine)
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1784
                        to:(oldStartLine?selectionStartLine max:selectionStartLine)
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1785
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1786
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1787
    (oldEndLine == selectionEndLine) ifTrue:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1788
        (oldEndCol notNil and:[oldEndCol ~~ selectionEndCol]) ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1789
            self redrawLine:oldEndLine
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1790
                       from:((selectionEndCol min:oldEndCol) max:1)
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1791
                         to:((selectionEndCol max:oldEndCol) max:1)
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1792
        ]
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1793
    ] ifFalse:[
4636
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1794
        selectionEndLine isNil ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1795
            selectionStartLine := nil.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1796
            self redraw.
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1797
        ] ifFalse:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1798
            (selectionStartLine notNil) ifTrue:[
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1799
                self redrawFromLine:(oldEndLine min:selectionEndLine)
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1800
                                 to:(oldEndLine max:selectionEndLine)
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1801
            ]
1354b5208c1f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4605
diff changeset
  1802
        ]
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1803
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1804
    clickLine := movedLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1805
    clickCol := movedCol
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1806
4234
65f202270d2c changed: #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 4178
diff changeset
  1807
    "Modified: / 05-04-2011 / 17:13:35 / cg"
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  1808
    "Modified: / 17-04-2012 / 21:00:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1809
!
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1810
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1811
keyPress:key x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1812
    "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
  1813
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1814
    <resource: #keyboard (#Find #Copy #FindNext #FindPrev #FindAgain
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1815
			  #GotoLine #SelectAll #SaveAs #Print
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1816
			  #'F*' #'f*' #ZoomIn #ZoomOut)>
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1817
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1818
    (key == #Find) ifTrue:[self search. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1819
    (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
  1820
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1821
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1822
    (key == #FindNext) ifTrue:[self searchFwd. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1823
    (key == #FindPrev) ifTrue:[self searchBwd. ^self].
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1824
    (key == #FindAgain) ifTrue:[self searchAgainInSameDirection. ^self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1825
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1826
    (key == #SelectAll) ifTrue:[self selectAll. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1827
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1828
    (key == #SaveAs)    ifTrue:[self save.    ^self].
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1829
    (key == #Print)     ifTrue:[self doPrint. ^self].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1830
4409
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  1831
    (key == #ZoomIn or:[key == #ZoomOut]) ifTrue:[ self fontLargerOrSmaller:(key == #ZoomIn) ].
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  1832
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1833
    "
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1834
     shift-Fn defines a key-sequence
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1835
     Fn       pastes that sequence
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1836
     cmd-Fn   performs a 'doIt' on the sequence (Workspaces only)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1837
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1838
     (see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1839
    "
1193
811135bbd017 Do not crash when typing simple keys.
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
  1840
    (key size > 1 and:[(key at:1) asLowercase == $f]) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1841
	(('[fF][0-9]' match:key)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1842
	or:['[fF][0-9][0-9]' match:key]) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1843
	    self sensor shiftDown ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1844
		UserPreferences current functionKeySequences
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1845
		    at:key put:(self selection)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1846
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1847
	    ^ self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1848
	].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1849
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1850
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1851
    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
  1852
4409
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  1853
    "Modified: / 18-04-1997 / 12:12:27 / stefan"
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  1854
    "Modified: / 10-03-2012 / 09:40:01 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1855
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1856
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1857
mapped
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1858
    super mapped.
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1859
    selectionFgColor := selectionFgColor onDevice:device.
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1860
    selectionBgColor := selectionBgColor onDevice:device.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1861
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1862
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1863
quadClickX:x y:y
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1864
    "quadrupleClick-click - select all"
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1865
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1866
    self selectAll
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1867
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1868
    "Created: / 11.9.1997 / 04:15:24 / cg"
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1869
    "Modified: / 31.3.1998 / 14:21:13 / cg"
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1870
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1871
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1872
tripleClickX:x y:y
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1873
    "triple-click - select line under pointer"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1874
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1875
    self selectLineAtY:y.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1876
    selectStyle := #line
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1877
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1878
    "Created: 11.9.1997 / 04:13:37 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1879
! !
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1880
2120
1054ce5c8fe7 category change
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
  1881
!TextView methodsFor:'initialization & release'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1882
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1883
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1884
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1885
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1886
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1887
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1888
    selectionFgColor notNil ifTrue:[selectionFgColor := selectionFgColor onDevice:device].
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1889
    selectionBgColor notNil ifTrue:[selectionBgColor := selectionBgColor onDevice:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1890
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1891
    "Created: 14.1.1997 / 00:14:33 / cg"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1892
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1893
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1894
initStyle
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1895
    "setup viewStyle specifics"
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1896
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1897
    super initStyle.
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
    viewBackground := DefaultViewBackground.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1900
    selectionFgColor := DefaultSelectionForegroundColor.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1901
    selectionFgColor isNil ifTrue:[selectionFgColor := bgColor].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1902
    selectionBgColor := DefaultSelectionBackgroundColor.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1903
    selectionBgColor isNil ifTrue:[
5099
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1904
        device hasColors ifTrue:[
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1905
            DefaultSelectionForegroundColor isNil ifTrue:[
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1906
                selectionFgColor := fgColor
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1907
            ].
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1908
            selectionBgColor := Color green
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1909
        ] ifFalse:[
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1910
            device hasGrayscales ifTrue:[
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1911
                DefaultSelectionForegroundColor isNil ifTrue:[
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1912
                    selectionFgColor := fgColor
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1913
                ].
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1914
                selectionBgColor := Color gray
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1915
            ] ifFalse:[
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1916
                selectionBgColor := fgColor
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1917
            ]
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  1918
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1919
    ].
708
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1920
4321
4c8c94f6e1c6 comemnt in: #initStyle
az
parents: 4310
diff changeset
  1921
    "Modified: / 22-01-1997 / 11:57:53 / cg"
4c8c94f6e1c6 comemnt in: #initStyle
az
parents: 4310
diff changeset
  1922
    "Modified (comment): / 05-10-2011 / 15:50:45 / az"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1923
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1924
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1925
initialize
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1926
    super initialize.
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1927
    self initializeSaveAction.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1928
    contentsWasSaved := false.
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1929
    dragIsActive     := false.
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  1930
    lastSearchWasMatch := lastSearchWasVariableSearch := false.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  1931
    lastSearchIgnoredCase := true.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1932
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1933
    parenthesisSpecification isNil ifTrue:[
4748
3f24bdf8a355 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4702
diff changeset
  1934
        parenthesisSpecification := DefaultParenthesisSpecification.
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1935
    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1936
911
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1937
    "I handle menus myself"
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1938
    menuHolder := menuPerformer := self.
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1939
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1940
    "/ on default allow drag
96256221e3af support drag
ca
parents: 2581
diff changeset
  1941
    self allowDrag:true.
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1942
!
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1943
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1944
initializeSaveAction
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1945
    saveAction := [ self openSaveDialog ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1946
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1947
4450
ef24b9b60ec1 category of:21 methods
Claus Gittinger <cg@exept.de>
parents: 4437
diff changeset
  1948
!TextView methodsFor:'menu & menu actions'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1949
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1950
appendTo:aFileName
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1951
    "append contents to a file named fileName"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1952
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1953
    |aStream msg filename|
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1954
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1955
    filename := aFileName asFilename.
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1956
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1957
    (FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1958
	msg := resources string:'Refused to append to file ''%1'' !!' with:filename name.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1959
	self warn:(msg , '\\(ST/X internal permission check)' ) withCRs.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1960
	^ self
2036
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1961
    ].
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1962
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1963
    [
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1964
	aStream := filename appendingWriteStream.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1965
	[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1966
	    self fileOutContentsOn:aStream compressTabs:true encoding:externalEncoding.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1967
	] ensure:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1968
	    aStream close.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1969
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1970
	contentsWasSaved := true
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1971
    ] on:FileStream openErrorSignal do:[:ex|
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1972
	msg := resources string:'cannot append to file %1 !!' with:filename name.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  1973
	self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1974
    ]
4437
561731a3d484 withWriteCursorDo
Claus Gittinger <cg@exept.de>
parents: 4419
diff changeset
  1975
561731a3d484 withWriteCursorDo
Claus Gittinger <cg@exept.de>
parents: 4419
diff changeset
  1976
    "Modified: / 27-07-2012 / 09:41:18 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1977
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1978
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1979
changeFont
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1980
    "pop up a fontPanel to change font"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1981
411
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1982
    |newFont|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1983
5005
2acadbbf1bce class: TextView
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1984
    self withWaitCursorDo:[
2acadbbf1bce class: TextView
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1985
        newFont := FontPanel fontFromUserInitial:font.
2acadbbf1bce class: TextView
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1986
    ].
411
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1987
    newFont notNil ifTrue:[
5005
2acadbbf1bce class: TextView
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1988
        self font:newFont.
411
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1989
    ]
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1990
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1991
    "Modified: 27.2.1996 / 00:53:51 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1992
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1993
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1994
copySelection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1995
    "copy contents into smalltalk copybuffer"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1996
863
ed4282df00a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 860
diff changeset
  1997
    |text|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1998
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1999
    text := self selection.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2000
    text notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2001
	self unselect.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2002
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2003
	"/ forget any emphasis ...
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2004
	text := text collect:[:l | l isNil ifTrue:[l] ifFalse:[l string]].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2005
	self setClipboardText:text.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2006
    ]
649
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2007
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2008
    "Modified: 17.5.1996 / 08:57:54 / cg"
248
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
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2011
defaultForGotoLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2012
    "return a default value to show in the gotoLine box"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2013
447
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  2014
    ^ selectionStartLine
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  2015
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  2016
    "Modified: 1.3.1996 / 18:44:36 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2017
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2018
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2019
doPrint
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2020
    "print the contents on the printer"
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2021
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2022
    |printStream|
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2023
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2024
    list isNil ifTrue:[^ self].
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2025
829
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  2026
    self withWaitCursorDo:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2027
	printStream := Printer new.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2028
	printStream supportsContext ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2029
	    printStream printerContext font:(self font).
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2030
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2031
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2032
	Printer writeErrorSignal handle:[:ex |
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2033
	    self warn:('error while printing:\\'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2034
			, ex description
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2035
			, '\\(printing with: ' , (Printer printCommand) , ')') withCRs
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2036
	] do:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2037
	    self fileOutContentsOn:printStream.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2038
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2039
	printStream close
829
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  2040
    ].
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  2041
4363
4ed2feefc2c2 changed: #doPrint
Claus Gittinger <cg@exept.de>
parents: 4361
diff changeset
  2042
    "Created: / 06-05-1996 / 16:11:26 / cg"
4ed2feefc2c2 changed: #doPrint
Claus Gittinger <cg@exept.de>
parents: 4361
diff changeset
  2043
    "Modified: / 31-01-2012 / 18:16:39 / cg"
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2044
!
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  2045
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2046
editMenu
1109
83d8c0143ef9 commentary
Claus Gittinger <cg@exept.de>
parents: 1100
diff changeset
  2047
    "return my popUpMenu"
83d8c0143ef9 commentary
Claus Gittinger <cg@exept.de>
parents: 1100
diff changeset
  2048
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  2049
    <resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)>
1262
d69149b5be1f resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  2050
    <resource: #programMenu>
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  2051
1545
1812c587358f use new popupMenu creation
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  2052
    |items m|
1812c587358f use new popupMenu creation
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  2053
1812c587358f use new popupMenu creation
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  2054
    items := #(
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2055
			('Copy'          copySelection  Copy)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2056
			('-'             nil            )
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2057
			('Search...'     search         Find)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2058
			('Goto Line...'  gotoLine       GotoLine)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2059
			('-'             nil            )
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2060
			('Font...'       changeFont     )
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2061
			('-'             nil            )
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2062
			('Save As...'    save           SaveAs)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2063
			('Print'         doPrint        Print)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2064
		).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2065
1545
1812c587358f use new popupMenu creation
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  2066
    m := PopUpMenu itemList:items resources:resources.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2067
2350
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  2068
    self hasSelectionForCopy ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2069
	m disable:#copySelection.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2070
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2071
    ^ m
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  2072
2458
4a61ac0ba64c menu order
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  2073
    "Modified: / 12.11.2001 / 13:43:56 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2074
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2075
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2076
find
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2077
    "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
  2078
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2079
    self search
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2080
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2081
    "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
  2082
!
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2083
4409
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2084
fontLargerOrSmaller:largerBoolean
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2085
    |newFont|
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2086
4785
7b72e2622200 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4779
diff changeset
  2087
    newFont := font asSize:(largerBoolean
7b72e2622200 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4779
diff changeset
  2088
                            ifTrue:[font size + 1]
7b72e2622200 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4779
diff changeset
  2089
                            ifFalse:[(font size-1) max:4]).
4409
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2090
    self font:newFont.
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2091
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2092
    "Modified: / 27-02-1996 / 00:53:51 / cg"
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2093
    "Created: / 10-03-2012 / 09:38:32 / cg"
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2094
!
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2095
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2096
gotoLine
1524
60582bfee9ce allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents: 1496
diff changeset
  2097
    "show a box to enter lineNumber for positioning;
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2098
     The entered number may be prefixed by a + or -;
1926
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  2099
     in this case, the linenumber is taken relative to the current position."
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  2100
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  2101
    |l lineNumberBox input lineToGo relative|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2102
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2103
    lineNumberBox :=
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2104
	EnterBox
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2105
	   title:(resources string:'Line number (or +/- relativeNr):')
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2106
	   okText:(resources string:'Goto')
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2107
	   abortText:(resources string:'Cancel')
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2108
	   action:[:l | input := l].
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2109
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2110
    l := self defaultForGotoLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2111
    l notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2112
	l := l printString
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2113
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2114
    lineNumberBox initialText:l .
3394
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
  2115
    lineNumberBox label:(resources string:'Goto Line').
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2116
    lineNumberBox showAtPointer.
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2117
1524
60582bfee9ce allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents: 1496
diff changeset
  2118
    input size > 0 ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2119
	input := input withoutSpaces.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2120
	input size > 0 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2121
	    (input startsWith:$+) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2122
		relative := 1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2123
	    ] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2124
		(input startsWith:$-) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2125
		    relative := -1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2126
		].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2127
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2128
	    relative notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2129
		input := input copyFrom:2.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2130
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2131
	    lineToGo := Integer readFromString:input onError:nil.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2132
	    lineToGo notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2133
		relative notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2134
		    lineToGo := self currentLine + (lineToGo * relative)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2135
		].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2136
		self gotoLine:lineToGo
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2137
	    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2138
	]
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2139
    ].
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2140
1524
60582bfee9ce allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents: 1496
diff changeset
  2141
    "Modified: / 17.5.1998 / 20:07:59 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2142
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2143
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2144
openSaveDialog
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2145
    "Ask user for filename using a fileSelectionBox
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2146
     and save contents into that file."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2147
2695
7e13db2802df better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents: 2693
diff changeset
  2148
    Dialog
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2149
	requestSaveFileName:(resources string:'Save contents in:')
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2150
	default:defaultFileNameForFileDialog
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2151
	fromDirectory:directoryForFileDialog
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2152
	action:[:fileName | self saveAs:fileName]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2153
	appendAction:[:fileName | self appendTo:fileName]
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2154
!
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2155
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2156
openSearchBoxAndSearch
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2157
    "search for a string - show a box to enter searchpattern
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2158
     - currently no regular expressions are handled."
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2159
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2160
    "
4985
414cb5cbe48f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4885
diff changeset
  2161
     Q: is it a good idea to preserve the last searchstring between views?
414cb5cbe48f class: TextView
Claus Gittinger <cg@exept.de>
parents: 4885
diff changeset
  2162
     cg: yes - turns out to be useful and less confusing than keeping last per view
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2163
    "
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2164
    |searchBox patternHolder caseHolder matchHolder fwd ign match initialString
4485
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2165
     bindings bldr doSearch modal searchVariableHolder selectedVariable searchFullWordHolder
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
  2166
     replaceBooleanEnabledHolder replaceBooleanHolder replaceTextHolder
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
  2167
     searchAtBeginOfLineOnlyHolder|
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2168
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2169
    searchBarActionBlock notNil ifTrue:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2170
        self resetVariablesBeforeNewSearch.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2171
        searchBarActionBlock value:#search value:self.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2172
        ^ self
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2173
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2174
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2175
    modal := (UserPreferences current searchDialogIsModal).   "/ thats experimental
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2176
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2177
    ign := lastSearchIgnoredCase "? LastSearchIgnoredCase " ? true.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2178
    caseHolder := ign not asValue.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2179
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2180
    match := lastSearchWasMatch ? LastSearchWasMatch ? false.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2181
    matchHolder := match asValue.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2182
    searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue.
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2183
    searchFullWordHolder := false asValue.
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
  2184
    searchAtBeginOfLineOnlyHolder := false asValue.
4485
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2185
    replaceBooleanHolder := false asValue.
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2186
    replaceTextHolder := '' asValue.
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2187
    replaceBooleanEnabledHolder := self isReadOnly not asValue.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2188
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2189
    patternHolder := '' asValue.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2190
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2191
    self setSearchPatternWithMatchEscapes: match.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2192
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2193
    lastSearchPattern notNil ifTrue:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2194
        initialString := lastSearchPattern.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2195
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2196
"/  No longer force the current selection to be the initialString
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2197
"/    self hasSelectionWithinSingleLine ifTrue:[
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2198
"/        initialString := self selection asString.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2199
"/    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2200
    initialString isNil ifTrue:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2201
        LastSearchPatterns size > 0 ifTrue:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2202
            initialString := LastSearchPatterns first.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2203
        ]
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2204
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2205
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2206
    initialString notNil ifTrue:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2207
        patternHolder value:initialString.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2208
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2209
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2210
    fwd := true.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2211
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2212
    doSearch := [:fwd |
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2213
        |isVariableSearch pattern searchAction|
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2214
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2215
        self resetVariablesBeforeNewSearch.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2216
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2217
        isVariableSearch := self searchVariableVisible
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2218
                                and:[searchVariableHolder value
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2219
                                and:[selectedVariable notNil]].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2220
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2221
        isVariableSearch ifTrue:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2222
            searchAction := [self searchVariableWithSyntaxElement:selectedVariable forward:fwd].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2223
        ] ifFalse:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2224
            lastSearchWasVariableSearch := false.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2225
            LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not).
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2226
            LastSearchWasMatch := lastSearchWasMatch := matchHolder value.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2227
            pattern := patternHolder value.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2228
            pattern notEmptyOrNil ifTrue:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2229
                searchAction := [
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2230
                    self searchUsingSpec:(
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2231
                        ListView::SearchSpec new
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2232
                            pattern:pattern
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2233
                            ignoreCase:lastSearchIgnoredCase
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2234
                            match: lastSearchWasMatch
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2235
                            variable: searchVariableHolder value
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2236
                            fullWord: searchFullWordHolder value
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
  2237
                            forward:fwd
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
  2238
                            atBeginOfLineOnly:searchAtBeginOfLineOnlyHolder value).
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2239
                ]
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2240
            ]
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2241
        ].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2242
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2243
        replaceBooleanHolder value ifTrue:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2244
            |selStart|
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2245
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2246
            isVariableSearch ifTrue:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2247
                "/ must replace from the end towards beginning,
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2248
                "/ because syntax-elements do not update their position, when
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2249
                "/ the text is changed (in replace).
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2250
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2251
                selectedVariable := selectedVariable lastElementInChain.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2252
                self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2253
                searchAction := [selectedVariable := selectedVariable previousElement.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2254
                                 selectedVariable notNil ifTrue:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2255
                                     self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2256
                                 ].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2257
                                 "/ self searchVariableWithSyntaxElement:selectedVariable forward:false
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2258
                                ].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2259
            ].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2260
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2261
            selStart := self characterPositionOfSelection.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2262
            self replace:(replaceTextHolder value).
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2263
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2264
            searchAction value.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2265
            [self characterPositionOfSelection ~= selStart] whileTrue:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2266
                selStart := self characterPositionOfSelection.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2267
                self replace:(replaceTextHolder value).
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2268
                searchAction value.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2269
            ]
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2270
        ] ifFalse:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2271
            searchAction value.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2272
        ].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2273
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2274
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2275
    bindings := IdentityDictionary new.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2276
    bindings at:#searchPattern put:patternHolder.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2277
    modal ifTrue:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2278
        bindings at:#nextAction put:[searchBox doAccept.].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2279
        bindings at:#prevAction put:[fwd := false. searchBox doAccept.].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2280
    ] ifFalse:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2281
        bindings at:#nextAction put:[doSearch value:true.  "searchBox doAccept."].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2282
        bindings at:#prevAction put:[doSearch value:false. "fwd := false. searchBox doAccept."].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2283
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2284
    bindings at:#caseSensitive put:caseHolder.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2285
    bindings at:#match put:matchHolder.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2286
    bindings at:#patternList put:LastSearchPatterns.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2287
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2288
    self supportsSyntaxElements ifFalse:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2289
        bindings at:#searchVariableVisible put:false.
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2290
    ] ifTrue:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2291
        bindings at:#searchVariableVisible put:true.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2292
        selectedVariable := self syntaxElementForSelectedVariable.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2293
        bindings at:#searchVariableEnabled put:(selectedVariable notNil).
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2294
        selectedVariable notNil ifTrue:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2295
            bindings
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2296
                at:#stringWithVariableUnderCursorHolder
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2297
                put:('Variable ("%1")' bindWith:selectedVariable value).
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2298
            searchVariableHolder value:true.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2299
        ] ifFalse:[
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2300
            bindings
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2301
                at:#stringWithVariableUnderCursorHolder
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2302
                put:('Variable (none selected)').
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2303
        ].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2304
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2305
    bindings at:#searchVariable put:searchVariableHolder.
4485
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2306
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2307
    bindings at:#searchFullWord put:searchFullWordHolder.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2308
    bindings at:#searchFullWordEnabled put:true.
5077
9c8e1b153493 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5070
diff changeset
  2309
    bindings at:#searchAtBeginOfLineOnly put:searchAtBeginOfLineOnlyHolder.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2310
4485
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2311
    bindings at:#replaceEnabled put:replaceBooleanEnabledHolder.
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2312
    bindings at:#replaceBoolean put:replaceBooleanHolder.
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2313
    bindings at:#replaceTextHolder put:replaceTextHolder.
5010
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
  2314
    replaceBooleanHolder onChangeEvaluate:
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
  2315
        [
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
  2316
            replaceBooleanHolder value ifTrue:[
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
  2317
                (bldr componentAt:#ReplaceEntryField) requestFocus   
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
  2318
            ] ifFalse:[
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
  2319
                (bldr componentAt:#patternComboBox) requestFocus   
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
  2320
            ].
ad4a10879e16 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
  2321
        ].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2322
    modal ifTrue:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2323
        searchBox := SimpleDialog new.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2324
    ] ifFalse:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2325
        searchBox := ApplicationModel new.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2326
        searchBox createBuilder.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2327
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2328
    searchBox resources:(self resources).
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2329
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2330
    bldr := searchBox builder.
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2331
    bldr addBindings:bindings.
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2332
    bldr aspectAt:#flyByHelpSpec put:(self class flyByHelpSpec).
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2333
    searchBox allButOpenFrom:(self class searchDialogSpec).
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2334
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2335
    (bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2336
    (bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2337
    (bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2338
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2339
    modal ifTrue:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2340
        searchBox openDialog.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2341
        searchBox accepted ifTrue:[ doSearch value:fwd ].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2342
    ] ifFalse:[
4864
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2343
        (bldr componentAt:#nextButton) isReturnButton:false.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2344
        (bldr componentAt:#cancelButton)
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2345
                label:(resources string:'Close');
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2346
                action:[searchBox closeRequest].
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2347
        "/ searchBox masterApplication:self application.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2348
        self topView beMaster.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2349
        searchBox window
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2350
                beSlave;
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2351
                openInGroup:(self windowGroup).
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2352
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2353
        "/ searchBox window open.
50303241e6d9 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4804
diff changeset
  2354
        searchBox window assignKeyboardFocusToFirstInputField.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2355
    ]
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2356
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2357
    "Modified: / 11-07-2006 / 11:18:38 / fm"
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2358
    "Created: / 08-03-2012 / 14:02:59 / cg"
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2359
!
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2360
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2361
save
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2362
    "save contents into a file
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2363
     - ask user for filename using a fileSelectionBox."
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  2364
3201
ce84e272c6bb code cleanup
Claus Gittinger <cg@exept.de>
parents: 3189
diff changeset
  2365
    saveAction value
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2366
!
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
saveAs:fileName
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  2369
    "save the contents into a file named fileName"
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2370
2488
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  2371
    ^ self saveAs:fileName doAppend:false
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  2372
!
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  2373
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  2374
saveAs:aFilename doAppend:doAppend
2488
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  2375
    "save the contents into a file named fileName;
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  2376
     if doAppend is true, the views contents is appended to the existing
2834
be970a6f9333 return true for successful save
penk
parents: 2822
diff changeset
  2377
     contents - otherwise, it overwrites any previous file contents.
be970a6f9333 return true for successful save
penk
parents: 2822
diff changeset
  2378
     on error return false otherwise return true"
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  2379
4534
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2380
    ^ self saveAs:aFilename doAppend:doAppend compressTabs:true
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2381
!
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2382
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2383
saveAs:aFilename doAppend:doAppend compressTabs:compressTabs
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2384
    "save the contents into a file named fileName;
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2385
     if doAppend is true, the views contents is appended to the existing
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2386
     contents - otherwise, it overwrites any previous file contents.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2387
     on error return false otherwise return true"
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2388
3426
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2389
    |filename msg|
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  2390
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  2391
    filename := aFilename asFilename.
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  2392
4437
561731a3d484 withWriteCursorDo
Claus Gittinger <cg@exept.de>
parents: 4419
diff changeset
  2393
    self withWriteCursorDo:[
4534
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2394
        |aStream|
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2395
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2396
        (FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2397
            msg := resources 
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2398
                        stringWithCRs:'Refused to write file ''%1'' !!\(ST/X internal permission check)'
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2399
                        with:filename name.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2400
        ] ifTrue:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2401
            [
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2402
                doAppend ifTrue:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2403
                    aStream := filename appendingWriteStream.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2404
                ] ifFalse:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2405
                    aStream := filename newReadWriteStream.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2406
                ].
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2407
                self fileOutContentsOn:aStream compressTabs:compressTabs encoding:externalEncoding.
4648
e2792f0b2b47 class: TextView
Stefan Vogel <sv@exept.de>
parents: 4636
diff changeset
  2408
                aStream syncData; close.
4534
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2409
                contentsWasSaved := true.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2410
                defaultFileNameForFileDialog := filename.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2411
            ] on:FileStream openErrorSignal do:[:ex|
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2412
                msg := resources stringWithCRs:'Cannot write file ''%1'' !!\(%2)'
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2413
                                with:filename name
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2414
                                with:FileStream lastErrorString.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2415
            ].
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2416
        ].
2834
be970a6f9333 return true for successful save
penk
parents: 2822
diff changeset
  2417
    ].
3426
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2418
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2419
    msg notNil ifTrue:[
4534
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2420
        Dialog warn:msg.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2421
        ^ false
3426
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2422
    ].
2834
be970a6f9333 return true for successful save
penk
parents: 2822
diff changeset
  2423
    ^ true
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  2424
4437
561731a3d484 withWriteCursorDo
Claus Gittinger <cg@exept.de>
parents: 4419
diff changeset
  2425
    "Modified: / 27-07-2012 / 09:45:13 / cg"
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2426
!
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2427
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2428
search
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2429
    "search for a string - show a box to enter searchpattern
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2430
     - 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
  2431
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2432
    self openSearchBoxAndSearch
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2433
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2434
    "Modified: / 11-07-2006 / 11:18:38 / fm"
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2435
    "Modified: / 08-03-2012 / 14:03:10 / cg"
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2436
!
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2437
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2438
search:patternArg ignoreCase:ign forward:fwd
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2439
    "search for a string without matching"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2440
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2441
    self search:patternArg ignoreCase:ign match: false forward:fwd
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2442
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2443
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2444
search:patternArg ignoreCase:ign match: match forward:fwd
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2445
    |pattern|
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2446
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2447
    pattern := patternArg string.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2448
    pattern notEmpty ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2449
	self rememberSearchPattern:pattern.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2450
	"/ LastSearchIgnoredCase := lastSearchIgnoredCase := ign.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2451
	"/ LastSearchWasMatch := match.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2452
	fwd ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2453
	    lastSearchDirection := #backward.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2454
	    self searchBwd:pattern ignoreCase:ign match: match.          "    backward search with match is not yet available  "
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2455
	] ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2456
	    lastSearchDirection := #forward.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2457
	    self searchFwd:pattern ignoreCase:ign match: match.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2458
	]
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2459
    ]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2460
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2461
    "Created: / 11-07-2006 / 11:18:04 / fm"
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  2462
    "Modified: / 23-03-2012 / 12:12:07 / cg"
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2463
!
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2464
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2465
searchUsingSpec:aSearchSpec
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2466
    self rememberSearchPattern:(aSearchSpec pattern).
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2467
    "/ LastSearchIgnoredCase := lastSearchIgnoredCase := ign.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2468
    "/ LastSearchWasMatch := match.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2469
    aSearchSpec forward ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2470
	lastSearchDirection := #backward.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2471
	self searchBwdUsingSpec:aSearchSpec
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2472
    ] ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2473
	lastSearchDirection := #forward.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2474
	self searchFwdUsingSpec:aSearchSpec
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2475
    ]
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2476
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2477
    "Created: / 11-07-2006 / 11:18:04 / fm"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2478
    "Modified: / 23-03-2012 / 12:12:07 / cg"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2479
!
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2480
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2481
searchVariableVisible
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2482
    "search variable option in searchbox visible?
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2483
     (only true for codeview2's textview)"
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2484
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2485
    ^ false
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2486
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2487
    "Created: / 08-03-2012 / 14:01:24 / cg"
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2488
!
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2489
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2490
searchVariableWithSyntaxElement:syntaxElementForVariable forward:fwd
4485
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2491
    "this only works for CodeView2::TextView, which supports syntaxElements.
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  2492
     Finds the next occurrence of a syntax element (typically, a variable)"
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  2493
4409
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2494
    |el el2|
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2495
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2496
    lastSearchWasVariableSearch := true.
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2497
    el := fwd
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2498
	ifTrue:[syntaxElementForVariable nextElement]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2499
	ifFalse:[syntaxElementForVariable previousElement].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2500
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2501
    el notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2502
	"bug workaround"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2503
	(el start = syntaxElementForVariable start) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2504
	    el2 := fwd
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2505
		ifTrue:[el nextElement]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2506
		ifFalse:[el previousElement].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2507
	    el2 notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2508
		el := el2
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2509
	    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2510
	].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2511
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2512
    el notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2513
	self selectFromCharacterPosition:el start to:el stop.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2514
	self makeLineVisible:(self lineOfCharacterPosition:el start).
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2515
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2516
	self showNotFound
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2517
    ].
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2518
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2519
    "Created: / 08-03-2012 / 14:08:20 / cg"
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2520
!
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2521
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2522
syntaxElementForSelectedVariable
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2523
    "for a better search; ignored here, but redefined in CodeView2"
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2524
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2525
    ^ nil
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2526
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2527
    "Created: / 08-03-2012 / 14:20:27 / cg"
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2528
!
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2529
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2530
syntaxElementForVariableUnderCursor
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2531
    "for a better search; ignored here, but redefined in CodeView2"
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2532
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2533
    ^ nil
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2534
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  2535
    "Created: / 08-03-2012 / 12:45:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2536
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2537
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2538
!TextView methodsFor:'private'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2539
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2540
currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2541
    ^  selectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2542
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2543
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2544
currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2545
    ^ selectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2546
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2547
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2548
fileOutContentsOn:aStream
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2549
    "save contents on a stream, replacing leading spaces by tab-characters."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2550
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2551
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2552
	fileOutContentsOn:aStream
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2553
	compressTabs:true
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2554
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2555
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2556
fileOutContentsOn:aStream compressTabs:compressTabs
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2557
    "save contents on a stream. If compressTabs is true,
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2558
     leading spaces will be replaced by tab-characters in the output."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2559
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2560
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2561
	fileOutContentsOn:aStream
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2562
	compressTabs:compressTabs
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2563
	encoding:nil
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2564
!
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2565
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2566
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
  2567
    "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
  2568
     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
  2569
2877
cdaea8ccd364 encoding
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
  2570
    |startNr nLines string encoder|
cdaea8ccd364 encoding
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
  2571
2945
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2572
    self removeTrailingWhitespace.
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2573
2877
cdaea8ccd364 encoding
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
  2574
    encoder := CharacterEncoder encoderToEncodeFrom:characterEncoding into:encodingSymOrNil.
4455
febe97112d50 changed: #fileOutContentsOn:compressTabs:encoding:
Claus Gittinger <cg@exept.de>
parents: 4450
diff changeset
  2575
    encoder isNullEncoder ifTrue:[
4534
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2576
        (list contains:[:lineOrNil|
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2577
                            |s|
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2578
                            lineOrNil notNil
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2579
                            and:[(s := lineOrNil string string) isWideString
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2580
                            and:[s asSingleByteStringIfPossible isWideString]]
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2581
                       ]
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2582
        ) ifTrue:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2583
            (Dialog confirm:'The text contains non-8bit characters. Encode as UTF8?') ifFalse:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2584
                ^ self
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2585
            ]
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2586
        ].
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2587
        encoder := CharacterEncoder encoderToEncodeFrom:#unicode into:#utf8
4455
febe97112d50 changed: #fileOutContentsOn:compressTabs:encoding:
Claus Gittinger <cg@exept.de>
parents: 4450
diff changeset
  2588
    ].
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
  2589
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  2590
    aStream isFileStream ifTrue:[
4534
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2591
        "on some systems, writing linewise is very slow (via NFS)
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2592
         therefore we convert to a string and write it in big chunks.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2593
         To avoid creating huge strings, we do it in blocks of 1000 lines,
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2594
         limiting temporary string creation to about 50-80k.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2595
        "
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2596
        startNr := 1.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2597
        nLines := list size.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2598
        [startNr <= nLines] whileTrue:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2599
            string := list 
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2600
                        asStringWithCRsFrom:startNr
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2601
                        to:((startNr + 1000) min:nLines)
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2602
                        compressTabs:compressTabs.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2603
            aStream nextPutAll:(encoder encodeString:string string).
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2604
            startNr := startNr + 1000 + 1.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2605
        ].
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  2606
    ] ifFalse:[
4534
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2607
        list do:[:aLine |
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2608
            aLine notNil ifTrue:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2609
                aStream nextPutLine:(encoder encodeString:aLine).
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2610
            ] ifFalse:[
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2611
                aStream cr.
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2612
            ]
bfd6c9687185 TextView
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
  2613
        ]
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  2614
    ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2615
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  2616
    "Modified: 8.6.1996 / 11:50:46 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2617
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2618
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2619
getFontParameters
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2620
    "get some info of the used font. They are cached since we use them often ..
4779
9f7633fc5583 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4767
diff changeset
  2621
     This is redefined here, to use the font's maxHeight/maxAscent for
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2622
     line separation. This is required, to allow for proper handling of
4779
9f7633fc5583 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4767
diff changeset
  2623
     national characters, such as A-diaresis ..."
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2624
4569
f2d3ecfde0ff class: TextView
Claus Gittinger <cg@exept.de>
parents: 4567
diff changeset
  2625
    |italicFont boldFont fA iA bA|
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2626
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  2627
    font := font onDevice:device.
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2628
    italicFont := font asItalic onDevice:device.
3304
bd0991615b04 When computing font parameters, now consider the bold font, too.
Stefan Vogel <sv@exept.de>
parents: 3298
diff changeset
  2629
    boldFont := font asBold onDevice:device.
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2630
4779
9f7633fc5583 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4767
diff changeset
  2631
    fontHeight := font height max:(italicFont height max:(boldFont height)).
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2632
    includesNonStrings == true ifTrue:[
4569
f2d3ecfde0ff class: TextView
Claus Gittinger <cg@exept.de>
parents: 4567
diff changeset
  2633
        "/ for now, we do not support variable height entries ...
4779
9f7633fc5583 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4767
diff changeset
  2634
        fontHeight := fontHeight max:(list first heightOn:self).
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2635
    ].
4579
3a5a72358a0a class: TextView
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
  2636
    fontHeight := fontHeight + lineSpacing.
3a5a72358a0a class: TextView
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
  2637
    fA := font ascent. 
3a5a72358a0a class: TextView
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
  2638
    "/ fA := font maxAscent. 
3a5a72358a0a class: TextView
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
  2639
    iA := italicFont ascent. 
3a5a72358a0a class: TextView
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
  2640
    "/ iA := italicFont maxAscent. 
3a5a72358a0a class: TextView
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
  2641
    bA := boldFont ascent. 
3a5a72358a0a class: TextView
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
  2642
    "/ bA := boldFont maxAscent. 
4569
f2d3ecfde0ff class: TextView
Claus Gittinger <cg@exept.de>
parents: 4567
diff changeset
  2643
    fontAscent := fA max:(iA max:bA).
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2644
    fontWidth := font width.
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2645
    fontIsFixedWidth := font isFixedWidth and:[ italicFont isFixedWidth and:[ boldFont isFixedWidth ]].
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2646
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2647
    "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
  2648
    "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
  2649
!
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2650
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2651
isClosingParenthesis:ch
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2652
    ((parenthesisSpecification at:#close) includes:ch) ifTrue:[^ true].
4368
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  2653
    ^ ')]}' includes:ch
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  2654
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  2655
    "Modified: / 12-02-2012 / 08:37:01 / cg"
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2656
!
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2657
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2658
isOpeningParenthesis:ch
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2659
    ((parenthesisSpecification at:#open) includes:ch) ifTrue:[^ true].
4368
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  2660
    ^ '([{' includes:ch
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  2661
23ab3a7cf707 changed:
Claus Gittinger <cg@exept.de>
parents: 4363
diff changeset
  2662
    "Modified: / 12-02-2012 / 08:37:11 / cg"
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2663
!
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2664
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2665
rememberSearchPattern:pattern
2691
2c4350e0bcf8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  2666
    |nRemembered patternString|
2c4350e0bcf8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  2667
2814
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  2668
    self clearSearchAction.
2813
ec8e83691849 forget searchAction, when a new pattern-search is done
Claus Gittinger <cg@exept.de>
parents: 2811
diff changeset
  2669
2691
2c4350e0bcf8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  2670
    patternString := pattern string.
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2671
3270
e3ed37e15f9d oops - last-searchpatterns handling removed the wrong one.
Claus Gittinger <cg@exept.de>
parents: 3258
diff changeset
  2672
    nRemembered := NumRememberedSearchPatterns ? 20.
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2673
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2674
    LastSearchPatterns isNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2675
	LastSearchPatterns := OrderedCollection new.
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2676
    ].
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2677
    "/ move to top or addFirst
4409
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2678
    (LastSearchPatterns includes:patternString) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2679
	LastSearchPatterns remove:patternString.
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2680
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2681
	LastSearchPatterns size > nRemembered ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2682
	    LastSearchPatterns removeLast
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2683
	]
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2684
    ].
4409
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2685
    LastSearchPatterns addFirst:patternString.
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2686
37712dd0d074 variable searching
Claus Gittinger <cg@exept.de>
parents: 4408
diff changeset
  2687
    "Modified: / 23-03-2012 / 13:59:09 / cg"
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2688
!
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2689
2945
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2690
removeTrailingWhitespace
3001
d9877eeb59f5 *** empty log message ***
ca
parents: 2992
diff changeset
  2691
    list isNil ifTrue:[^self].
2945
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2692
    list keysAndValuesDo:[:lineNR :line |
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2693
	|l|
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2694
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2695
	line notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2696
	    l := line withoutTrailingSeparators.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2697
	    list at:lineNR put:l.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2698
	]
2945
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2699
    ].
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2700
!
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2701
4009
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2702
resetVariablesBeforeNewSearch
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2703
    "clear the autosearch action, when the first pattern is searched for"
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2704
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2705
    searchAction := nil.
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2706
!
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2707
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2708
scrollSelectDown
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2709
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2710
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2711
    |prevEndLine|
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
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2714
    selectionEndLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2715
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2716
    self scrollDown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2717
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2718
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2719
    prevEndLine := selectionEndLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2720
    selectionEndLine := firstLineShown + nFullLinesShown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2721
    selectionEndCol := 0.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2722
    prevEndLine to:selectionEndLine do:[:lineNr |
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2723
	self redrawLine:lineNr
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2724
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2725
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  2726
    self selectionChanged.
248
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
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2729
scrollSelectLeft
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2730
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2731
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2732
    |prevStartLine|
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
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2735
    selectionStartLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2736
    selectionStartCol isNil ifTrue:[^ self].
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
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2739
    prevStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2740
    selectionStartCol := selectionStartCol - 1 max:1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2741
    self scrollLeft.
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
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  2744
    self selectionChanged.
248
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
scrollSelectRight
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2748
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2749
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2750
    |prevEndCol firstVisibleCol endLine|
248
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
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2753
    selectionEndCol isNil ifTrue:[^ self].
4169
11d3b7a3e713 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4160
diff changeset
  2754
    selectionEndLine isNil ifTrue:[^ self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2755
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2756
    prevEndCol := selectionEndCol.
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2757
    selectionEndCol := (selectionEndCol + 1) min:(self listAt:selectionEndLine) size.
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2758
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2759
    endLine := self listLineToVisibleLine:selectionEndLine.
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2760
    endLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2761
	firstVisibleCol := self colOfX:1 inVisibleLine:endLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2762
	selectionEndCol < firstVisibleCol ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2763
	    "/ scrolling faster than selection advances...
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2764
	    selectionEndCol := firstVisibleCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2765
	].
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2766
    ].
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2767
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2768
    self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2769
    self scrollRight.
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2770
    "/ self repairDamage.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2771
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2772
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2773
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2774
    "Modified: / 05-08-2010 / 21:25:56 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2775
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2776
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2777
scrollSelectUp
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2778
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2779
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2780
    |prevStartLine|
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
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2783
    selectionStartLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2784
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2785
    self scrollUp.
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
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2788
    prevStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2789
    selectionStartLine := firstLineShown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2790
    selectionStartCol := 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2791
    selectionStartLine to:prevStartLine do:[:lineNr |
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2792
	self redrawLine:lineNr
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2793
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2794
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  2795
    self selectionChanged.
248
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
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2798
stopScrollSelect
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2799
    "stop auto scroll; deinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2800
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2801
    autoScrollBlock notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2802
	Processor removeTimedBlock:autoScrollBlock.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2803
	self compressMotionEvents:true.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2804
	autoScrollBlock := nil.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2805
	autoScrollDeltaT := nil
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2806
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2807
!
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
widthForScrollBetween:firstLine and:lastLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2810
    "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
  2811
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2812
    selectionStartLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2813
	"/ if there is a selection which covers multiple lines,
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2814
	"/ we have to scroll the whole width (to include the selection-rectangle)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2815
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2816
	(lastLine < selectionStartLine) ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2817
	    (firstLine > selectionEndLine) ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2818
		^ width
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2819
	    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2820
	].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2821
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2822
    ^ super widthForScrollBetween:firstLine and:lastLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2823
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2824
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2825
!TextView methodsFor:'queries'!
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2826
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2827
hasSearchActionSelection
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2828
    "Here we fake the use of typeOfSelection which is really in EditTextView"
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2829
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2830
    ^ false
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2831
!
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2832
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2833
specClass
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2834
    "redefined, since the name of my specClass is nonStandard (i.e. not TextViewSpec)"
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2835
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2836
    self class == TextView ifTrue:[^ TextEditorSpec].
1046
10da5b6bd390 specClass query
ca
parents: 1028
diff changeset
  2837
    ^ super specClass
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2838
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2839
    "Modified: / 31.10.1997 / 19:48:35 / cg"
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2840
! !
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2841
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2842
!TextView methodsFor:'redrawing'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2843
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2844
clearMarginOfVisibleLine:visLine with:color
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2845
    "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
  2846
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2847
    (leftMargin ~~ 0) ifTrue:[
4602
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  2848
        viewOrigin x <= margin ifTrue:[
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  2849
            self paint:color.
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  2850
            self fillRectangleX:margin-viewOrigin x
4667
7e25c2ca1182 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4648
diff changeset
  2851
                              y:(self yOfVisibleLine:visLine)- (lineSpacing//2)
4602
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  2852
                          width:leftMargin
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  2853
                         height:fontHeight
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  2854
        ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2855
    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2856
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2857
    "Created: 6.3.1996 / 14:22:55 / cg"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2858
!
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2859
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2860
drawSelectedFromVisibleLine:startVisLineNr to:endVisLineNr
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2861
    startVisLineNr to:endVisLineNr do:[:visLine |
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2862
	self drawVisibleLineSelected:visLine
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2863
    ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2864
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2865
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2866
drawVisibleLineSelected:visLineNr
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2867
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2868
	drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr))
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2869
	inVisible:visLineNr
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2870
	with:self currentSelectionFgColor and:self currentSelectionBgColor
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2871
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2872
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2873
drawVisibleLineSelected:visLineNr col:col
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2874
    self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2875
	drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr))
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2876
	inVisible:visLineNr
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2877
	col:col
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2878
	with:self currentSelectionFgColor and:self currentSelectionBgColor
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2879
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2880
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2881
drawVisibleLineSelected:visLineNr from:selectionStartCol
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2882
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2883
	drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr))
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2884
	inVisible:visLineNr
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2885
	from:selectionStartCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2886
	with:self currentSelectionFgColor and:self currentSelectionBgColor.
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2887
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2888
2558
4c10bec1117d more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents: 2557
diff changeset
  2889
drawVisibleLineSelected:visLineNr from:startCol to:endCol
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2890
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2891
	drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr))
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2892
	inVisible:visLineNr
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2893
	from:startCol to:endCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2894
	with:self currentSelectionFgColor and:self currentSelectionBgColor.
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2895
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2896
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2897
redrawFromVisibleLine:startVisLineNr to:endVisLineNr
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2898
    "redraw a visible line range"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2899
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2900
    |startLine endLine specialCare end selVisStart line1 line2|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2901
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2902
    shown ifFalse:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2903
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2904
    end := endVisLineNr.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2905
    (end > nLinesShown) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2906
	end := nLinesShown
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2907
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2908
2740
892dfb6b0da1 kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents: 2735
diff changeset
  2909
    selectionEndLine isNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2910
	selectionStartLine := nil
2740
892dfb6b0da1 kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents: 2735
diff changeset
  2911
    ].
2735
5ba2010aefa4 *** empty log message ***
penk
parents: 2730
diff changeset
  2912
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2913
    selectionStartLine isNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2914
	specialCare := false
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2915
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2916
	startLine := self visibleLineToAbsoluteLine:startVisLineNr.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2917
	(startLine > selectionEndLine) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2918
	    specialCare := false
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2919
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2920
	    endLine := self visibleLineToAbsoluteLine:end.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2921
	    (endLine < selectionStartLine) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2922
		specialCare := false
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2923
	    ] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2924
		specialCare := true
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2925
	    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2926
	]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2927
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2928
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2929
    "easy: nothing is selected"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2930
    specialCare ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2931
	super redrawFromVisibleLine:startVisLineNr to:end.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2932
	^ self
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2933
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2934
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2935
    "easy: all is selected"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2936
    ((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2937
	self drawSelectedFromVisibleLine:startVisLineNr to:end.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2938
	^ self
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2939
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2940
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2941
    (selectionStartLine >= firstLineShown) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2942
	"draw unselected top part"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2943
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2944
	selVisStart := self listLineToVisibleLine:selectionStartLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2945
	super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1).
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2946
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2947
	"and first partial selected line"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2948
	self redrawVisibleLine:selVisStart.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2949
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2950
	"rest starts after this one"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2951
	line1 := selVisStart + 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2952
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2953
	line1 := 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2954
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2955
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2956
    (line1 > end) ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2957
    (line1 < startVisLineNr) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2958
	line1 := startVisLineNr
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2959
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2960
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2961
    "draw middle part of selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2962
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2963
    (selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2964
	line2 := nLinesShown
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2965
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2966
	line2 := (self listLineToVisibleLine:selectionEndLine) - 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2967
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2968
    (line2 > end) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2969
	line2 := end
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2970
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2971
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2972
    self drawSelectedFromVisibleLine:line1 to:line2.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2973
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2974
    (line2 >= end) ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2975
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2976
    "last line of selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2977
    self redrawVisibleLine:(line2 + 1).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2978
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2979
    ((line2 + 2) <= end) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  2980
	super redrawFromVisibleLine:(line2 + 2) to:end
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2981
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2982
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2983
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2984
redrawVisibleLine:visLineNr
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2985
    "redraw visible line lineNr"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2986
2558
4c10bec1117d more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents: 2557
diff changeset
  2987
    |line|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2988
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2989
    (selectionStartLine notNil and:[selectionEndLine notNil
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2990
    and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2991
        line := self visibleLineToAbsoluteLine:visLineNr.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2992
        (line between:selectionStartLine and:selectionEndLine) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2993
            (line == selectionStartLine) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2994
                (line == selectionEndLine) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2995
                    "it's part-of-single-line selection"
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2996
                    self clearMarginOfVisibleLine:visLineNr with:bgColor.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2997
                    (selectionStartCol > 1) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2998
                        super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1)
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  2999
                    ].
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3000
                    self drawVisibleLineSelected:visLineNr from:selectionStartCol to:selectionEndCol.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3001
                    super redrawVisibleLine:visLineNr from:(selectionEndCol + 1).
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3002
                    ^ self
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3003
                ].
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3004
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3005
                "it's the first line of a multi-line selection"
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3006
                (selectionStartCol ~~ 1) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3007
                    self clearMarginOfVisibleLine:visLineNr with:bgColor.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3008
                    super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1)
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3009
                ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3010
                    viewOrigin x == 0 ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3011
                        self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3012
                    ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3013
                ].
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3014
                self drawVisibleLineSelected:visLineNr from:selectionStartCol.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3015
                ^ self
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3016
            ].
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3017
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3018
            (line == selectionEndLine) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3019
                "it's the last line of a multi-line selection"
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3020
                (selectionEndCol == 0) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3021
                    ^ super redrawVisibleLine:visLineNr
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3022
                ].
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3023
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3024
                self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3025
                self drawVisibleLineSelected:visLineNr from:1 to:selectionEndCol.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3026
                super redrawVisibleLine:visLineNr from:(selectionEndCol + 1).
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3027
                ^ self
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3028
            ].
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3029
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3030
            "it's a full line in a multi-line selection"
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3031
            self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3032
            self drawVisibleLineSelected:visLineNr.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3033
            ^ self
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3034
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3035
    ].
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  3036
    super redrawVisibleLine:visLineNr
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3037
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3038
    "Modified: 6.3.1996 / 14:22:19 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3039
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3040
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3041
redrawVisibleLine:visLine col:col
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  3042
    "redraw single character at col in visible line lineNr."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3043
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  3044
    |line|
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  3045
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  3046
    "/
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  3047
    "/ care for selection
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  3048
    "/
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3049
    (selectionStartLine notNil and:[selectionEndLine notNil
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3050
    and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3051
        line := self visibleLineToAbsoluteLine:visLine.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3052
        (line between:selectionStartLine and:selectionEndLine) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3053
            ((line == selectionStartLine)
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3054
            and: [col < selectionStartCol]) ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3055
                ((line == selectionEndLine)
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3056
                and: [col > selectionEndCol]) ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3057
                    "its in the selection"
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3058
                    self drawVisibleLineSelected:visLine col:col.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3059
                    ^ self.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3060
                ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3061
            ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3062
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3063
    ].
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  3064
    self drawVisibleLine:visLine col:col with:fgColor and:bgColor
1496
95a24d9211df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3065
95a24d9211df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3066
    "Modified: / 22.4.1998 / 08:53:05 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3067
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3068
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3069
redrawVisibleLine:visLine from:startCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3070
    "redraw visible line lineNr from startCol to end of line"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3071
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3072
    |col line|
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3073
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3074
    col := startCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3075
    col == 0 ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3076
	col := 1.
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3077
    ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3078
2778
223915a2d6a4 kludge workaround selectionEndLine is sometimes nil
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  3079
    (selectionStartLine notNil and:[selectionEndLine notNil]) ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3080
	line := self visibleLineToAbsoluteLine:visLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3081
	(line between:selectionStartLine and:selectionEndLine) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3082
	    ((line == selectionStartLine)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3083
	     or:[line == selectionEndLine]) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3084
		"since I'm lazy, redraw full line"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3085
		self redrawVisibleLine:visLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3086
		^ self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3087
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3088
	    "the line is fully within the selection"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3089
	    self drawVisibleLineSelected:visLine from:col.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3090
	    ^ self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3091
	]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3092
    ].
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3093
    super redrawVisibleLine:visLine from:col
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3094
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3095
    "Modified: 6.3.1996 / 14:19:38 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3096
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3097
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3098
redrawVisibleLine:visLine from:startCol to:endCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3099
    "redraw visible line lineNr from startCol to endCol"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3100
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3101
    |line allOut allIn leftCol rightCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3102
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3103
    line := self visibleLineToAbsoluteLine:visLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3104
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3105
    allIn := false.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3106
    allOut := false.
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3107
    (selectionStartLine isNil or:[selectionEndLine isNil
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3108
    or:[selectionStartCol isNil or:[selectionEndCol isNil]]]) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3109
        allOut := true
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3110
    ] ifFalse:[
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3111
        (line between:selectionStartLine and:selectionEndLine) ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3112
            allOut := true
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3113
        ] ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3114
            (selectionStartLine == selectionEndLine) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3115
                ((endCol < selectionStartCol)
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3116
                or:[startCol > selectionEndCol]) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3117
                    allOut := true
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3118
                ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3119
                    ((startCol >= selectionStartCol)
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3120
                    and:[endCol <= selectionEndCol]) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3121
                        allIn := true
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3122
                    ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3123
                ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3124
            ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3125
                (line == selectionStartLine) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3126
                    (endCol < selectionStartCol) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3127
                        allOut := true
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3128
                    ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3129
                        (startCol >= selectionStartCol) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3130
                            allIn := true
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3131
                        ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3132
                    ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3133
                ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3134
                    (line == selectionEndLine) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3135
                        (startCol > selectionEndCol) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3136
                            allOut := true
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3137
                        ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3138
                            (endCol <= selectionEndCol) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3139
                                allIn := true
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3140
                            ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3141
                        ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3142
                    ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3143
                        allIn := true
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3144
                    ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3145
                ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3146
            ]
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3147
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3148
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3149
    allOut ifTrue:[
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3150
        super redrawVisibleLine:visLine from:startCol to:endCol.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3151
        ^ self
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3152
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3153
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3154
    allIn ifTrue:[
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3155
        self drawVisibleLineSelected:visLine from:startCol to:endCol
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3156
    ] ifFalse:[
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3157
        "redraw part before selection"
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3158
        ((line == selectionStartLine)
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3159
         and:[startCol <= selectionStartCol]) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3160
            super redrawVisibleLine:visLine from:startCol
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3161
                                              to:(selectionStartCol - 1).
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3162
            leftCol := selectionStartCol
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3163
        ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3164
            leftCol := startCol
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3165
        ].
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3166
        "redraw selected part"
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3167
        (selectionEndLine > line) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3168
            rightCol := endCol
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3169
        ] ifFalse:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3170
            rightCol := selectionEndCol min:endCol
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3171
        ].
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3172
        self drawVisibleLineSelected:visLine from:leftCol to:rightCol.
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3173
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3174
        "redraw part after selection"
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3175
        (rightCol < endCol) ifTrue:[
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3176
            super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3177
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3178
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3179
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3180
    "special care for first and last line of selection:
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3181
     must handle margin also"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3182
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3183
    ((line == selectionEndLine)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3184
    and:[(startCol == 1)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3185
    and:[selectionStartLine < selectionEndLine]])
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3186
    ifTrue:[
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3187
        self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3188
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3189
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3190
    ((line == selectionStartLine)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3191
    and:[(startCol == 1)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3192
    and:[selectionStartLine < selectionEndLine]])
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3193
    ifTrue:[
4528
527c90bfd2cc class: TextView
Claus Gittinger <cg@exept.de>
parents: 4500
diff changeset
  3194
        self clearMarginOfVisibleLine:visLine with:bgColor.
4602
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  3195
    ].
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  3196
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  3197
    ((line > selectionStartLine)
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  3198
    and:[(startCol == 1)
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  3199
    and:[selectionStartLine < selectionEndLine
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  3200
    and:[line < selectionEndLine]]])
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  3201
    ifTrue:[
e487576b81a7 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4579
diff changeset
  3202
        self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3203
    ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3204
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3205
    "Modified: 6.3.1996 / 14:23:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3206
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3207
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3208
!TextView methodsFor:'searching'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3209
2814
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  3210
clearSearchAction
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  3211
    searchAction := nil.
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  3212
!
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  3213
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3214
scanFor:aCharacter fromLine:startLine col:startCol forward:forward
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3215
		     ifFound:foundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3216
		  ifNotFound:notFoundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3217
    "search for a character in the direction given by forward.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3218
     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
  3219
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3220
    |lineString
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3221
     line   "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3222
     col    "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3223
     delta  "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3224
     endCol "{ Class: SmallInteger }"
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3225
     cc
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3226
     maxLine "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3227
      |
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3228
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3229
    col := startCol.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3230
    line := startLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3231
    forward ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3232
	delta := 1.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3233
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3234
	delta := -1.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3235
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3236
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3237
    lineString := list at:line.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3238
    maxLine := list size.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3239
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3240
    col := col + delta.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3241
    [true] whileTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3242
	lineString notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3243
	    forward ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3244
		endCol := lineString size.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3245
	    ] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3246
		endCol := 1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3247
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3248
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3249
	    col to:endCol by:delta do:[:rCol |
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3250
		cc := lineString at:rCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3251
		cc == aCharacter ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3252
		    ^ foundBlock value:line value:rCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3253
		]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3254
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3255
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3256
	line := line + delta.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3257
	(line < 1 or:[line > maxLine]) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3258
	    ^ notFoundBlock value
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3259
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3260
	lineString := list at:line.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3261
	forward ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3262
	    col := 1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3263
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3264
	    col := lineString size
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3265
	]
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3266
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3267
    "not reached"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3268
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3269
    "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
  3270
    "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
  3271
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3272
3802
sr
parents: 3792
diff changeset
  3273
searchAction
sr
parents: 3792
diff changeset
  3274
    ^ searchAction
sr
parents: 3792
diff changeset
  3275
!
sr
parents: 3792
diff changeset
  3276
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3277
searchAction:aSearcherOrSearchBlock
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3278
    searchAction := aSearcherOrSearchBlock
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3279
!
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3280
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3281
searchAgainInSameDirection
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3282
    "search again in the same direction and -if found- position cursor"
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3283
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3284
    |ign match|
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3285
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  3286
    searchBarActionBlock notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3287
	searchBarActionBlock value:#forward value:self.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3288
	^ self
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3289
    ].
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3290
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3291
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3292
    match := lastSearchWasMatch ? LastSearchWasMatch ? false.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3293
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3294
    self setSearchPatternWithMatchEscapes: match.
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3295
    lastSearchPattern notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3296
	lastSearchDirection == #backward ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3297
	    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3298
		searchBwd:lastSearchPattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3299
		ignoreCase:ign
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3300
		match: match
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3301
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3302
	    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3303
		searchFwd:lastSearchPattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3304
		ignoreCase:ign
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3305
		match: match
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3306
	]
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3307
    ]
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3308
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3309
    "Created: / 03-05-1999 / 15:02:16 / cg"
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3310
    "Modified: / 21-09-2006 / 16:47:57 / cg"
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3311
!
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3312
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3313
searchBwd
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3314
    "search backward (for the same thing again)
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3315
     If found, position cursor"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3316
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  3317
    |ign selectedVariable|
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  3318
2811
3a7aed97fd76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2809
diff changeset
  3319
    searchAction notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3320
	"/autosearch is cleared whenever there is search with user selection
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3321
	(self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction].
4178
db73b9c9a3f4 changed: #searchBwd
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
  3322
    ].
db73b9c9a3f4 changed: #searchBwd
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
  3323
db73b9c9a3f4 changed: #searchBwd
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
  3324
    searchAction notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3325
	"/confusing: this is for autosearch of variables (browse variable uses, for example)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3326
	self searchUsingSearchAction:#backward.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3327
	^ self.
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3328
    ].
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  3329
    searchBarActionBlock notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3330
	searchBarActionBlock value:#backward value:self.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3331
	^ self
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3332
    ].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  3333
    lastSearchWasVariableSearch ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3334
	selectedVariable := self syntaxElementForSelectedVariable.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3335
	selectedVariable notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3336
	    self searchVariableWithSyntaxElement:selectedVariable forward:false.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3337
	    ^ self.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3338
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3339
	lastSearchWasVariableSearch := false.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  3340
    ].
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3341
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3342
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  3343
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3344
    self setSearchPatternWithMatchEscapes: false.
2414
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3345
    lastSearchPattern isNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3346
	LastSearchPatterns size > 0 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3347
	    lastSearchPattern := LastSearchPatterns first
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3348
	]
2414
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3349
    ].
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3350
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3351
    lastSearchPattern notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3352
	lastSearchDirection := #backward.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3353
	self rememberSearchPattern:lastSearchPattern.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3354
	self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3355
	    searchBwd:lastSearchPattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3356
	    ignoreCase:ign
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3357
    ]
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3358
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  3359
    "Modified: / 08-03-2012 / 14:26:25 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3360
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3361
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3362
searchBwd:pattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3363
    "do a backward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3364
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3365
    self searchBwd:pattern ifAbsent:[self showNotFound].
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3366
"/    lastSearchIgnoredCase := false.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3367
    lastSearchPattern := pattern string
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3368
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3369
    "Modified: / 21-09-2006 / 16:48:29 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3370
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3371
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3372
searchBwd:pattern ifAbsent:aBlock
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3373
    "do a backward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3374
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3375
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3376
	searchBwdUsingSpec:(ListView::SearchSpec new
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3377
					pattern:pattern)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3378
	ifAbsent:aBlock
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3379
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3380
    "Modified: 13.9.1997 / 01:05:49 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3381
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3382
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3383
searchBwd:pattern ignoreCase:ign
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3384
    "do a backward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3385
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3386
    self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3387
	searchBwd:pattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3388
	ignoreCase:ign
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3389
	ifAbsent:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3390
		    self sensor compressKeyPressEventsWithKey:#FindPrev.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3391
		    self showNotFound
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3392
		 ].
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  3393
    "/ lastSearchIgnoredCase := ign.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3394
    lastSearchPattern := pattern string
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3395
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  3396
    "Created: / 13-09-1997 / 06:18:00 / cg"
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  3397
    "Modified: / 23-03-2012 / 12:10:25 / cg"
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3398
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3399
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3400
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3401
    "do a backward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3402
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3403
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3404
	searchBwdUsingSpec:(ListView::SearchSpec new
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3405
					pattern:pattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3406
					ignoreCase:ign)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3407
	ifAbsent:aBlock
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3408
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3409
    "Modified: 13.9.1997 / 01:05:49 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3410
    "Created: 13.9.1997 / 06:18:41 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3411
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3412
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3413
searchBwd:pattern ignoreCase:ign match: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3414
    "do a backward search.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3415
    match pattern functionality is not yet available for backward search"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3416
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  3417
    "/ lastSearchWasMatch := match.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3418
    self searchBwd:pattern ignoreCase:ign.
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  3419
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  3420
    "Modified: / 23-03-2012 / 12:12:44 / cg"
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3421
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3422
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3423
searchBwdUsingSpec:searchSpec
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3424
    "do a backward search"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3425
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3426
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3427
	searchBwdUsingSpec:searchSpec
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3428
	ifAbsent:[self showNotFound].
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3429
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3430
"/    lastSearchIgnoredCase := false.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3431
    lastSearchPattern := searchSpec pattern string
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3432
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3433
    "Modified: / 21-09-2006 / 16:48:29 / cg"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3434
!
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3435
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3436
searchBwdUsingSpec:searchSpec ifAbsent:aBlock
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3437
    "do a backward search"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3438
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3439
    |pos startLine startCol|
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3440
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3441
    pos :=  self startPositionForSearchBackward.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3442
    startLine := pos y.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3443
    startCol := pos x.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3444
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3445
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3446
	searchBackwardUsingSpec:searchSpec
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3447
	startingAtLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3448
	ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3449
	ifAbsent:aBlock
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3450
!
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3451
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3452
searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3453
    "select characters enclosed by matching parenthesis if one is under startLine/Col"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3454
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3455
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3456
	searchForMatchingParenthesisFromLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3457
	ifFound:[:line :col |
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3458
		  self selectFromLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3459
			       toLine:line col:col]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3460
	ifNotFound:[self showNotFound]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3461
	onError:[self beep]
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3462
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3463
    "Modified: 9.10.1997 / 12:57:34 / cg"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3464
!
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3465
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3466
searchForMatchingParenthesisFromLine:startLine col:startCol
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3467
		     ifFound:foundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3468
		  ifNotFound:notFoundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3469
		     onError:failBlock
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3470
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3471
    "search for a matching parenthesis; start search with character at startLine/startCol.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3472
     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
  3473
     backwards if its a closing parenthesis.
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3474
     Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3475
     If there is a nesting error, evaluate failBlock."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3476
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3477
    ^ self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3478
	searchForMatchingParenthesisFromLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3479
	ifFound:foundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3480
	ifNotFound:notFoundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3481
	onError:failBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3482
	ignoring:(parenthesisSpecification at:#ignore ifAbsent:#()) "/ #( $' $" '$[' '$]' '${' '$)' )
3478
13c5be5a11fe match without ignore
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
  3483
13c5be5a11fe match without ignore
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
  3484
    "Modified: / 12-04-2007 / 11:24:24 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3485
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3486
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3487
searchForMatchingParenthesisFromLine:startLine col:startCol
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3488
		     ifFound:foundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3489
		  ifNotFound:notFoundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3490
		     onError:failBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3491
		    ignoring:ignoreSet
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3492
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3493
    "search for a matching parenthesis; start search with character at startLine/startCol.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3494
     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
  3495
     backwards if its a closing parenthesis.
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3496
     Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3497
     If there is a nesting error, evaluate failBlock."
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3498
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3499
    ^ self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3500
	searchForMatchingParenthesisFromLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3501
	ifFound:foundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3502
	ifNotFound:notFoundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3503
	onError:failBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3504
	openingCharacters: (parenthesisSpecification at:#open)  "/ #( $( $[ ${ "$> $<")
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3505
	closingCharacters: (parenthesisSpecification at:#close) "/ #( $) $] $} "$> $<")
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3506
	ignoredCharacters: ignoreSet
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3507
	specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3508
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3509
"/    |i direction lineString
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3510
"/     parChar charSet  closingChar
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3511
"/     ignoring
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3512
"/     line   "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3513
"/     col    "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3514
"/     delta  "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3515
"/     endCol "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3516
"/     runCol "{ Class: SmallInteger }"
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3517
"/     cc prevCC nextCC incSet decSet
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3518
"/     nesting "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3519
"/     maxLine "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3520
"/     ign skip anySet|
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3521
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3522
"/    charSet := #( $( $) $[ $] ${ $} " $< $> " ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3523
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3524
"/    parChar := self characterAtLine:startLine col:startCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3525
"/    i := charSet indexOf:parChar.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3526
"/    i == 0 ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3527
"/        ^ failBlock value   "not a parenthesis"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3528
"/    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3529
"/    direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3530
"/    closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3531
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3532
"/    col := startCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3533
"/    line := startLine.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3534
"/    direction == #fwd ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3535
"/        delta := 1.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3536
"/        incSet := #( $( $[ ${ "$<" ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3537
"/        decSet := #( $) $] $} "$>" ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3538
"/    ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3539
"/        delta := -1.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3540
"/        incSet := #( $) $] $} "$>" ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3541
"/        decSet := #( $( $[ ${ "$<" ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3542
"/    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3543
"/    anySet := Set new.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3544
"/    anySet addAll:incSet; addAll:decSet; addAll:ignoreSet.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3545
"/    anySet := (anySet select:[:c | c isCharacter]) asString.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3546
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3547
"/    nesting := 1.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3548
"/    ignoring := false.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3549
"/    lineString := list at:line.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3550
"/    maxLine := list size.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3551
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3552
"/    col := col + delta.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3553
"/    [nesting ~~ 0] whileTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3554
"/        (lineString notNil
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3555
"/        and:[lineString includesAny:anySet]) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3556
"/            direction == #fwd ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3557
"/                endCol := lineString size.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3558
"/            ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3559
"/                endCol := 1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3560
"/            ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3561
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3562
"/            col to:endCol by:delta do:[:rCol |
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3563
"/                runCol := rCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3564
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3565
"/                cc := lineString at:runCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3566
"/                runCol < lineString size ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3567
"/                    nextCC := lineString at:runCol+1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3568
"/                ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3569
"/                    nextCC := nil
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3570
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3571
"/                runCol > 1 ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3572
"/                    prevCC := lineString at:runCol-1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3573
"/                ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3574
"/                    prevCC := nil
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3575
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3576
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3577
"/                ign := skip := false.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3578
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3579
"/                "/ check for comments.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3580
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3581
"/                ((cc == $" and:[nextCC == $/])
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3582
"/                or:[prevCC == $$ ]) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3583
"/                    "/ do nothing
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3584
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3585
"/                    skip := true.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3586
"/                ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3587
"/                    ignoreSet do:[:ignore |
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3588
"/                        ignore == cc ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3589
"/                            ign := true
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3590
"/                        ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3591
"/                            ignore isString ifTrue:[
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3592
"/                                cc == (ignore at:2) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3593
"/                                    runCol > 1 ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3594
"/                                        (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3595
"/                                            skip := true
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3596
"/                                        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3597
"/                                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3598
"/                                ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3599
"/                                    cc == (ignore at:1) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3600
"/                                        runCol < lineString size ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3601
"/                                            (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3602
"/                                                skip := true
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3603
"/                                            ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3604
"/                                        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3605
"/                                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3606
"/                                ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3607
"/                            ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3608
"/                        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3609
"/                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3610
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3611
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3612
"/                ign ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3613
"/                    ignoring := ignoring not
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3614
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3615
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3616
"/                ignoring ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3617
"/                    skip ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3618
"/                        (incSet includes:cc) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3619
"/                            nesting := nesting + 1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3620
"/                        ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3621
"/                            (decSet includes:cc) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3622
"/                                nesting := nesting - 1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3623
"/                            ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3624
"/                        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3625
"/                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3626
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3627
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3628
"/                nesting == 0 ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3629
"/                    "check if legal"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3630
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3631
"/                    skip ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3632
"/                        cc == closingChar ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3633
"/                            ^ failBlock value
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3634
"/                        ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3635
"/                        ^ foundBlock value:line value:runCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3636
"/                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3637
"/                ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3638
"/            ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3639
"/        ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3640
"/        line := line + delta.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3641
"/        (line < 1 or:[line > maxLine]) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3642
"/            ^ failBlock value
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3643
"/        ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3644
"/        lineString := list at:line.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3645
"/        direction == #fwd ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3646
"/            col := 1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3647
"/        ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3648
"/            col := lineString size
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3649
"/        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3650
"/    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3651
"/    ^ notFoundBlock value
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3652
3478
13c5be5a11fe match without ignore
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
  3653
    "Modified: / 12-04-2007 / 11:25:36 / cg"
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3654
!
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3655
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3656
searchForMatchingParenthesisFromLine:startLine col:startCol
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3657
		     ifFound:foundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3658
		  ifNotFound:notFoundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3659
		     onError:failBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3660
	   openingCharacters:openingCharacters
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3661
	   closingCharacters:closingCharacters
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3662
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3663
    "search for a matching parenthesis; start search with character at startLine/startCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3664
     Search for the corresponding character is done forward if its an opening,
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3665
     backwards if its a closing parenthesis.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3666
     Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3667
     If there is a nesting error, evaluate failBlock."
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3668
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3669
    ^ self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3670
	searchForMatchingParenthesisFromLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3671
	ifFound:foundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3672
	ifNotFound:notFoundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3673
	onError:failBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3674
	openingCharacters: openingCharacters
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3675
	closingCharacters: closingCharacters
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3676
	ignoredCharacters: (parenthesisSpecification at:#ignore ifAbsent:#())
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3677
	specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3678
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3679
"/    |i direction lineString
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3680
"/     parChar charSet  closingChar
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3681
"/     ignoring
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3682
"/     line   "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3683
"/     col    "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3684
"/     delta  "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3685
"/     endCol "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3686
"/     runCol "{ Class: SmallInteger }"
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3687
"/     cc prevCC nextCC incSet decSet
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3688
"/     nesting "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3689
"/     maxLine "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3690
"/     ign skip anySet|
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3691
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3692
"/    charSet := #( $( $) $[ $] ${ $} " $< $> " ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3693
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3694
"/    parChar := self characterAtLine:startLine col:startCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3695
"/    i := charSet indexOf:parChar.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3696
"/    i == 0 ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3697
"/        ^ failBlock value   "not a parenthesis"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3698
"/    ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3699
"/    direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3700
"/    closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3701
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3702
"/    col := startCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3703
"/    line := startLine.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3704
"/    direction == #fwd ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3705
"/        delta := 1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3706
"/        incSet := #( $( $[ ${ "$<" ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3707
"/        decSet := #( $) $] $} "$>" ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3708
"/    ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3709
"/        delta := -1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3710
"/        incSet := #( $) $] $} "$>" ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3711
"/        decSet := #( $( $[ ${ "$<" ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3712
"/    ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3713
"/    anySet := Set new.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3714
"/    anySet addAll:incSet; addAll:decSet; addAll:ignoreSet.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3715
"/    anySet := (anySet select:[:c | c isCharacter]) asString.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3716
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3717
"/    nesting := 1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3718
"/    ignoring := false.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3719
"/    lineString := list at:line.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3720
"/    maxLine := list size.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3721
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3722
"/    col := col + delta.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3723
"/    [nesting ~~ 0] whileTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3724
"/        (lineString notNil
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3725
"/        and:[lineString includesAny:anySet]) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3726
"/            direction == #fwd ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3727
"/                endCol := lineString size.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3728
"/            ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3729
"/                endCol := 1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3730
"/            ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3731
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3732
"/            col to:endCol by:delta do:[:rCol |
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3733
"/                runCol := rCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3734
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3735
"/                cc := lineString at:runCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3736
"/                runCol < lineString size ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3737
"/                    nextCC := lineString at:runCol+1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3738
"/                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3739
"/                    nextCC := nil
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3740
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3741
"/                runCol > 1 ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3742
"/                    prevCC := lineString at:runCol-1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3743
"/                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3744
"/                    prevCC := nil
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3745
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3746
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3747
"/                ign := skip := false.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3748
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3749
"/                "/ check for comments.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3750
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3751
"/                ((cc == $" and:[nextCC == $/])
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3752
"/                or:[prevCC == $$ ]) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3753
"/                    "/ do nothing
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3754
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3755
"/                    skip := true.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3756
"/                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3757
"/                    ignoreSet do:[:ignore |
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3758
"/                        ignore == cc ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3759
"/                            ign := true
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3760
"/                        ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3761
"/                            ignore isString ifTrue:[
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3762
"/                                cc == (ignore at:2) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3763
"/                                    runCol > 1 ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3764
"/                                        (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3765
"/                                            skip := true
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3766
"/                                        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3767
"/                                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3768
"/                                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3769
"/                                    cc == (ignore at:1) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3770
"/                                        runCol < lineString size ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3771
"/                                            (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3772
"/                                                skip := true
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3773
"/                                            ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3774
"/                                        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3775
"/                                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3776
"/                                ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3777
"/                            ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3778
"/                        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3779
"/                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3780
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3781
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3782
"/                ign ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3783
"/                    ignoring := ignoring not
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3784
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3785
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3786
"/                ignoring ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3787
"/                    skip ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3788
"/                        (incSet includes:cc) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3789
"/                            nesting := nesting + 1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3790
"/                        ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3791
"/                            (decSet includes:cc) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3792
"/                                nesting := nesting - 1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3793
"/                            ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3794
"/                        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3795
"/                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3796
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3797
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3798
"/                nesting == 0 ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3799
"/                    "check if legal"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3800
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3801
"/                    skip ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3802
"/                        cc == closingChar ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3803
"/                            ^ failBlock value
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3804
"/                        ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3805
"/                        ^ foundBlock value:line value:runCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3806
"/                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3807
"/                ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3808
"/            ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3809
"/        ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3810
"/        line := line + delta.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3811
"/        (line < 1 or:[line > maxLine]) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3812
"/            ^ failBlock value
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3813
"/        ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3814
"/        lineString := list at:line.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3815
"/        direction == #fwd ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3816
"/            col := 1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3817
"/        ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3818
"/            col := lineString size
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3819
"/        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3820
"/    ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3821
"/    ^ notFoundBlock value
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3822
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3823
    "Modified: / 12-04-2007 / 11:25:36 / cg"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3824
!
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3825
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3826
searchForMatchingParenthesisFromLine:startLine col:startCol
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3827
		     ifFound:foundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3828
		  ifNotFound:notFoundBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3829
		     onError:failBlock
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3830
	   openingCharacters:openingCharacters
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3831
	   closingCharacters:closingCharacters
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3832
	   ignoredCharacters:ignoreSet
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3833
	  specialEOLComment:eolCommentSequence
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3834
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3835
    "search for a matching parenthesis; start search with character at startLine/startCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3836
     Search for the corresponding character is done forward if its an opening,
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3837
     backwards if its a closing parenthesis.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3838
     Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3839
     If there is a nesting error, evaluate failBlock."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3840
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3841
    |i direction lineString
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3842
     parChar charSet  closingChar
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3843
     ignoring
770
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3844
     line   "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3845
     col    "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3846
     delta  "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3847
     endCol "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3848
     runCol "{ Class: SmallInteger }"
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3849
     cc prevCC nextCC incSet decSet
770
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3850
     nesting "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3851
     maxLine "{ Class: SmallInteger }"
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3852
     ign skip anySet
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3853
     eol1 eol2|
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3854
2772
4e04a3bf399f check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  3855
    self assert:(openingCharacters size == closingCharacters size).
4e04a3bf399f check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  3856
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3857
    charSet := openingCharacters , closingCharacters.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3858
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3859
    parChar := self characterAtLine:startLine col:startCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3860
    i := charSet indexOf:parChar.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3861
    i == 0 ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3862
	^ failBlock value   "not a parenthesis"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3863
    ].
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3864
3858
1fd3e63fb456 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  3865
    direction := (i <= openingCharacters size) ifTrue:[#fwd] ifFalse:[#bwd].
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3866
    closingChar := (closingCharacters , openingCharacters) at:i.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3867
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3868
    eol1 := eolCommentSequence at:1 ifAbsent:nil.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3869
    eol2 := eolCommentSequence at:2 ifAbsent:nil.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3870
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3871
    col := startCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3872
    line := startLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3873
    direction == #fwd ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3874
	delta := 1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3875
	incSet := openingCharacters.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3876
	decSet := closingCharacters.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3877
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3878
	delta := -1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3879
	incSet := closingCharacters.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3880
	decSet := openingCharacters.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3881
    ].
1454
ca768803f15d tuned searchForMatchingParen (with huge texts)
ca
parents: 1380
diff changeset
  3882
    anySet := Set new.
ca768803f15d tuned searchForMatchingParen (with huge texts)
ca
parents: 1380
diff changeset
  3883
    anySet addAll:incSet; addAll:decSet; addAll:ignoreSet.
ca768803f15d tuned searchForMatchingParen (with huge texts)
ca
parents: 1380
diff changeset
  3884
    anySet := (anySet select:[:c | c isCharacter]) asString.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3885
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3886
    nesting := 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3887
    ignoring := false.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3888
    lineString := list at:line.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3889
    maxLine := list size.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3890
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3891
    col := col + delta.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3892
    [nesting ~~ 0] whileTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3893
	(lineString notNil
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3894
	and:[lineString includesAny:anySet]) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3895
	    direction == #fwd ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3896
		endCol := lineString size.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3897
	    ] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3898
		endCol := 1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3899
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3900
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3901
	    col to:endCol by:delta do:[:rCol |
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3902
		runCol := rCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3903
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3904
		cc := lineString at:runCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3905
		runCol < lineString size ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3906
		    nextCC := lineString at:runCol+1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3907
		] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3908
		    nextCC := nil
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3909
		].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3910
		runCol > 1 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3911
		    prevCC := lineString at:runCol-1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3912
		] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3913
		    prevCC := nil
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3914
		].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3915
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3916
		ign := skip := false.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3917
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3918
		"/ check for comments.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3919
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3920
		((cc == eol1 and:[nextCC == eol2])
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3921
		or:[prevCC == $$ ]) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3922
		    "/ do nothing
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3923
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3924
		    skip := true.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3925
		] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3926
		    ignoreSet do:[:ignore |
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3927
			ignore == cc ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3928
			    ign := true
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3929
			] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3930
			    ignore isString ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3931
				cc == (ignore at:2) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3932
				    runCol > 1 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3933
					(lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3934
					    skip := true
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3935
					]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3936
				    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3937
				] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3938
				    cc == (ignore at:1) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3939
					runCol < lineString size ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3940
					    (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3941
						skip := true
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3942
					    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3943
					]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3944
				    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3945
				]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3946
			    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3947
			]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3948
		    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3949
		].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3950
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3951
		ign ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3952
		    ignoring := ignoring not
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3953
		].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3954
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3955
		ignoring ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3956
		    skip ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3957
			(incSet includes:cc) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3958
			    nesting := nesting + 1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3959
			] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3960
			    (decSet includes:cc) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3961
				nesting := nesting - 1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3962
			    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3963
			]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3964
		    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3965
		].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3966
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3967
		nesting == 0 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3968
		    "check if legal"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3969
		    skip ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3970
			cc == closingChar ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3971
			    ^ failBlock value
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3972
			].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3973
			^ foundBlock value:line value:runCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3974
		    ]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3975
		]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3976
	    ].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3977
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3978
	line := line + delta.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3979
	(line < 1 or:[line > maxLine]) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3980
	    ^ failBlock value
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3981
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3982
	lineString := list at:line.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3983
	direction == #fwd ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3984
	    col := 1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3985
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3986
	    col := lineString size
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  3987
	]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3988
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3989
    ^ notFoundBlock value
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3990
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  3991
    "Modified: 15.10.1996 / 12:22:30 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3992
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3993
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3994
searchFwd
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  3995
    "search forward for the same pattern or selection again"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3996
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  3997
    |ign match variable|
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  3998
2811
3a7aed97fd76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2809
diff changeset
  3999
    searchAction notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4000
	"/ autosearch is cleared whenever there is search with user selection
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4001
	(self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction].
4177
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  4002
    ].
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  4003
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  4004
    searchAction notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4005
	"/ confusing: this is for autosearch of variables (browse variable uses, for example)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4006
	self searchUsingSearchAction:#forward.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4007
	^ self.
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4008
    ].
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  4009
    searchBarActionBlock notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4010
	searchBarActionBlock value:#forward value:self.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4011
	^ self
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4012
    ].
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  4013
    lastSearchWasVariableSearch ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4014
	variable := self syntaxElementForSelectedVariable.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4015
	variable notNil ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4016
	    self searchVariableWithSyntaxElement:variable forward:true.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4017
	    ^ self.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4018
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4019
	lastSearchWasVariableSearch := false.
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  4020
    ].
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4021
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  4022
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4023
    match := lastSearchWasMatch ? LastSearchWasMatch ? false.
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  4024
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4025
    selectStyle == #wordLeft ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4026
	"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4027
	 remove the space from the selection
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4028
	"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4029
	selectionStartCol := selectionStartCol + 1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4030
	super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4031
	selectStyle := #word.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4032
	self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4033
    ].
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4034
    self setSearchPatternWithMatchEscapes: match.
2414
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  4035
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  4036
    lastSearchPattern isNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4037
	LastSearchPatterns size > 0 ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4038
	    lastSearchPattern := LastSearchPatterns first
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4039
	]
2414
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  4040
    ].
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  4041
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4042
    lastSearchPattern notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4043
	self rememberSearchPattern:lastSearchPattern.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4044
	lastSearchDirection := #forward.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4045
	self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4046
	    searchFwd:lastSearchPattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4047
	    ignoreCase:ign
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4048
	    match: match
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4049
    ]
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4050
4399
7e1e1a3a8fbf better search (variable)
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
  4051
    "Modified: / 08-03-2012 / 14:25:42 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4052
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4053
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4054
searchFwd:pattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4055
    "do a forward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4056
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4057
    self searchFwd:pattern ifAbsent:[self showNotFound].
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  4058
"/    lastSearchIgnoredCase := false.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  4059
    lastSearchPattern := pattern string
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  4060
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  4061
    "Modified: / 21-09-2006 / 16:52:04 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4062
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4063
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4064
searchFwd:pattern ifAbsent:aBlock
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4065
    "do a forward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4066
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4067
    self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4068
	searchFwdUsingSpec:(ListView::SearchSpec new
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4069
				pattern:pattern)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4070
	ifAbsent:aBlock
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4071
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  4072
    "Modified: / 21-09-2006 / 16:51:28 / cg"
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4073
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4074
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4075
searchFwd:pattern ignoreCase:ign
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4076
    "do a forward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4077
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4078
    self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4079
	searchFwdUsingSpec:(ListView::SearchSpec new
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4080
				pattern:pattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4081
				ignoreCase:ign)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4082
	ifAbsent:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4083
		    self sensor compressKeyPressEventsWithKey:#FindNext.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4084
		    self showNotFound
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4085
		 ].
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  4086
    "/ lastSearchIgnoredCase := ign.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  4087
    lastSearchPattern := pattern string
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  4088
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  4089
    "Created: / 13-09-1997 / 06:18:13 / cg"
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  4090
    "Modified: / 23-03-2012 / 12:09:59 / cg"
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4091
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4092
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4093
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4094
    "do a forward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4095
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4096
    self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4097
	searchFwdUsingSpec:(ListView::SearchSpec new
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4098
				pattern:pattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4099
				ignoreCase:ign)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4100
	ifAbsent:aBlock
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4101
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4102
    "Modified: 13.9.1997 / 01:05:35 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4103
    "Created: 13.9.1997 / 06:18:27 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4104
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4105
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4106
searchFwd:pattern ignoreCase:ign match: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4107
    "do a forward search"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4108
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4109
    self
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4110
	searchFwdUsingSpec:(ListView::SearchSpec new
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4111
				pattern:pattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4112
				ignoreCase:ign
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4113
				match:match)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4114
	ifAbsent:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4115
		    self sensor compressKeyPressEventsWithKey:#FindNext.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4116
		    self showNotFound
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4117
		 ].
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  4118
    "/ lastSearchIgnoredCase := ign.
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  4119
    "/ lastSearchWasMatch := match.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4120
    lastSearchPattern := pattern string
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4121
4408
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  4122
    "Created: / 13-09-1997 / 06:18:13 / cg"
1cba55e5141c changed:6 methods
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
  4123
    "Modified: / 23-03-2012 / 12:12:47 / cg"
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4124
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4125
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4126
searchFwd:pattern ignoreCase:ign match: match ifAbsent:aBlock
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4127
    "do a forward search"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4128
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4129
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4130
	searchFwdUsingSpec:(ListView::SearchSpec new
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4131
				pattern:pattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4132
				ignoreCase:ign
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4133
				match:match)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4134
	ifAbsent:aBlock
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4135
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4136
    "Modified: 13.9.1997 / 01:05:35 / cg"
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4137
    "Created: 13.9.1997 / 06:18:27 / cg"
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4138
!
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4139
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4140
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4141
    "do a forward search"
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  4142
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4143
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4144
	searchFwdUsingSpec:(ListView::SearchSpec new
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4145
				pattern:pattern
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4146
				ignoreCase:ign
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4147
				match:match)
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4148
	startingAtLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4149
	ifAbsent:aBlock
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4150
!
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4151
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4152
searchFwdUsingSpec:searchSpec
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4153
    "do a forward search"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4154
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4155
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4156
	searchFwdUsingSpec:searchSpec
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4157
	ifAbsent:[self showNotFound].
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4158
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4159
"/    lastSearchIgnoredCase := false.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4160
    lastSearchPattern := searchSpec pattern string
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4161
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4162
    "Modified: / 21-09-2006 / 16:52:04 / cg"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4163
!
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4164
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4165
searchFwdUsingSpec:searchSpec ifAbsent:aBlock
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4166
    "do a forward search"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4167
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4168
    |pos startLine startCol|
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4169
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4170
    pos := self startPositionForSearchForward.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4171
    startLine := pos y.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4172
    startCol := pos x.
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4173
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4174
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4175
	searchFwdUsingSpec:searchSpec
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4176
	startingAtLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4177
	ifAbsent:aBlock
4462
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4178
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4179
    "Modified: 13.9.1997 / 01:05:35 / cg"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4180
    "Created: 13.9.1997 / 06:18:27 / cg"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4181
!
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4182
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4183
searchFwdUsingSpec:searchSpec startingAtLine:startLine col:startCol ifAbsent:aBlock
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4184
    "do a forward search"
e7580f29c467 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
  4185
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4186
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4187
	searchForwardUsingSpec:searchSpec
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4188
	startingAtLine:startLine col:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4189
	ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4190
	ifAbsent:aBlock
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4191
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4192
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4193
searchPattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4194
    "return the last search pattern"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4195
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  4196
    ^ lastSearchPattern
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4197
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4198
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4199
searchUsingSearchAction:direction
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4200
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4201
	searchUsingSearchAction:direction
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4202
	ifAbsent:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4203
		    self sensor compressKeyPressEventsWithKey:#FindNext.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4204
		    self showNotFound
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4205
		 ]
2816
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  4206
!
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  4207
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  4208
searchUsingSearchAction:direction ifAbsent:notFoundAction
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4209
    |pos startLine startCol|
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4210
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4211
    pos :=  direction == #backward
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4212
		ifTrue:[self startPositionForSearchBackward]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4213
		ifFalse:[self startPositionForSearchForward].
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4214
    startLine := pos y.
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4215
    startCol := pos x.
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4216
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4217
    searchAction notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4218
	searchAction
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4219
	    value:direction
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4220
	    value:startLine
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4221
	    value:startCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4222
	    value:[:line :col | self selectFromLine:line toLine:line]
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4223
	    value:notFoundAction.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4224
	self hasSelection ifTrue: [
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4225
	    self changeTypeOfSelectionTo: #searchAction.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4226
	].
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4227
    ].
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4228
!
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  4229
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4230
setSearchPattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4231
    "set the searchpattern from the selection if there is one"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4232
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4233
    self setSearchPatternWithMatchEscapes: false.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4234
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4235
3904
dd4c2dace4f5 changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents: 3892
diff changeset
  4236
setSearchPattern:aStringOrNil
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4237
    "set the searchpattern for future searches"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4238
3904
dd4c2dace4f5 changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents: 3892
diff changeset
  4239
    aStringOrNil isEmptyOrNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4240
	lastSearchPattern := nil.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4241
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4242
	lastSearchPattern := aStringOrNil asString withoutSeparators string.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  4243
    ].
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  4244
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  4245
    "Modified: / 6.3.1999 / 23:47:36 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4246
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4247
2200
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  4248
setSearchPattern:aString ignoreCase:aBoolean
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  4249
    "set the searchpattern and caseIgnore for future searches"
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  4250
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  4251
    self setSearchPattern:aString.
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  4252
    lastSearchIgnoredCase := aBoolean.
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  4253
!
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  4254
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4255
setSearchPatternWithMatchEscapes: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4256
    "set the searchpattern from the selection if there is one"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4257
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4258
    |sel searchPattern |
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4259
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4260
"/    clickPos isNil ifTrue:[^ self].
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4261
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4262
    sel := self selection.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4263
    sel notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4264
	searchPattern := sel asString.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4265
	match ifTrue:[searchPattern := searchPattern withMatchEscapes].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4266
	self setSearchPattern:searchPattern.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4267
    ]
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4268
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4269
    "Modified: / 6.3.1999 / 23:48:04 / cg"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4270
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  4271
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4272
showMatch:pattern atLine:line col:col
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4273
    "after a search, highlight the matched pattern.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4274
     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
  4275
     (for now, it only highlights simple patterns and '*string*' correctly)"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4276
4120
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4277
    self showMatch:pattern isMatch:true atLine:line col:col
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4278
!
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4279
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4280
showMatch:pattern isMatch:isMatch atLine:line col:col
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4281
    "after a search, highlight the matched pattern.
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4282
     The code below needs a rewrite to take care of match-characters
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4283
     (for now, it only highlights simple patterns and '*string*' correctly)"
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4284
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4285
    |realPattern|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4286
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4287
    realPattern := pattern.
4120
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4288
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  4289
    isMatch ifTrue: [
4567
33be833bfcbf Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
  4290
        (realPattern startsWith:$*) ifTrue:[
5093
f69d248e1db0 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5092
diff changeset
  4291
            realPattern := realPattern copyButFirst
4567
33be833bfcbf Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
  4292
        ].
33be833bfcbf Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
  4293
        (realPattern endsWith:$*) ifTrue:[
5092
0108089c6550 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5078
diff changeset
  4294
            realPattern := realPattern copyButLast
4567
33be833bfcbf Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
  4295
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4296
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4297
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4298
    self selectFromLine:line col:col
4567
33be833bfcbf Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 4554
diff changeset
  4299
                 toLine:line col:(col + realPattern size - 1).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4300
    self makeLineVisible:line
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4301
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4302
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4303
showNotFound
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4304
    "search not found - tell user by beeping and changing
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4305
     cursor for a while (sometimes I work with a headset :-)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4306
     (used to be: tell user by changing cursor for a while)"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4307
5052
70780a6ab673 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5046
diff changeset
  4308
    self withCursor:(Cursor cross) do:[
70780a6ab673 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5046
diff changeset
  4309
        self beep.
70780a6ab673 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5046
diff changeset
  4310
        Processor activeProcess millisecondDelay:200.
1028
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  4311
    ]
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  4312
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  4313
    "Modified: 20.2.1997 / 12:49:27 / cg"
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4314
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4315
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4316
startPositionForSearchBackward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  4317
    ^ self startPositionForSearchBackwardBasedOnSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  4318
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  4319
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  4320
startPositionForSearchBackwardBasedOnSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4321
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4322
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4323
    selectionStartLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4324
	startLine := selectionStartLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4325
	startCol := selectionStartCol
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4326
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4327
	startLine := 1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4328
	startCol := 1
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4329
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4330
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4331
    ^ startCol @ startLine
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4332
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4333
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4334
startPositionForSearchForward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  4335
    ^ self startPositionForSearchForwardBasedOnSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  4336
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  4337
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  4338
startPositionForSearchForwardBasedOnSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4339
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4340
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4341
    selectionStartLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4342
	startLine := selectionStartLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4343
	startCol := selectionStartCol
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4344
    ] ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4345
	startLine := 1.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4346
	startCol := 1
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4347
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4348
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  4349
    ^ startCol @ startLine
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4350
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4351
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4352
!TextView methodsFor:'selections'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4353
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4354
changeTypeOfSelectionTo:newType
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4355
    "ignored here - but redefined in subclasses which
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4356
     differentiate between pasted- and user-selections"
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4357
!
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4358
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4359
expandSelectionDown
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4360
    |l t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4361
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4362
    selectionStartLine notNil ifTrue:[
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4363
        expandingTop == true ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4364
            l := selectionStartLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4365
            selectionStartLine := selectionStartLine + 1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4366
            (selectionStartLine > clickLine
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4367
            or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]])
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4368
            ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4369
                t := selectionStartLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4370
                selectionStartLine := selectionEndLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4371
                selectionEndLine := t.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4372
                t := selectionStartCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4373
                selectionStartCol := selectionEndCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4374
                selectionEndCol := t.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4375
                expandingTop := false
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4376
            ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4377
        ] ifFalse:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4378
            l := selectionEndLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4379
            selectionEndLine := selectionEndLine + 1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4380
        ].
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4381
"/        self redrawLine:l.
2442
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4382
"/        self redrawLine:l+1.
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4383
        self validateNewSelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4384
        self setPrimarySelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4385
        self selectionChanged.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4386
        self redrawFromLine:l to:l+1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4387
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4388
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4389
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4390
    "Created: / 01-03-1996 / 23:35:08 / cg"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4391
    "Modified: / 18-03-1996 / 17:18:15 / cg"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4392
    "Modified: / 17-04-2012 / 21:01:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4393
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4394
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4395
expandSelectionLeft
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  4396
    |c l t c1 c2|
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4397
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4398
    selectionStartLine notNil ifTrue:[
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4399
        expandingTop == true ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4400
            selectionStartCol == 0 ifTrue:[^ self].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4401
            l := selectionStartLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4402
            selectionStartCol := (selectionStartCol - 1) max:1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4403
            c := selectionStartCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4404
        ] ifFalse:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4405
            l := selectionEndLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4406
            selectionEndCol := (selectionEndCol - 1) max:0.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4407
            c := selectionEndCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4408
            selectionEndLine == selectionStartLine ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4409
                selectionEndCol <= selectionStartCol ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4410
                    t := selectionStartCol. selectionStartCol := selectionEndCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4411
                    selectionEndCol := t.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4412
                    expandingTop := true.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4413
                    c := selectionStartCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4414
                ]
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4415
            ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4416
        ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4417
        c1 := c.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4418
        c2 := c1 + 1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4419
        c1 == 0 ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4420
            c1 := 1
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4421
        ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4422
        self validateNewSelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4423
        self setPrimarySelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4424
        self selectionChanged.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4425
        self redrawLine:l from:c1 to:c2.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4426
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4427
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4428
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4429
    "Modified: / 18-03-1996 / 17:05:46 / cg"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4430
    "Modified: / 17-04-2012 / 21:01:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4431
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4432
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4433
expandSelectionRight
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4434
    |l c t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4435
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4436
    selectionStartLine notNil ifTrue:[
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4437
        expandingTop == true ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4438
            l := selectionStartLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4439
            c := selectionStartCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4440
            selectionStartCol := selectionStartCol + 1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4441
            l == selectionEndLine ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4442
                c >= selectionEndCol ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4443
                    expandingTop := false.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4444
                    t := selectionStartCol. selectionStartCol := selectionEndCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4445
                    selectionEndCol := t.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4446
                    c := selectionStartCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4447
                ]
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4448
            ]
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4449
        ] ifFalse:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4450
            l := selectionEndLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4451
            c := selectionEndCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4452
            selectionEndCol := selectionEndCol + 1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4453
        ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4454
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4455
        self validateNewSelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4456
        self setPrimarySelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4457
        self selectionChanged.
4804
8814768faf24 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4787
diff changeset
  4458
        self redrawLine:l from:(c max:1) to:c+1.
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4459
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4460
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4461
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4462
    "Created: / 01-03-1996 / 23:33:17 / cg"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4463
    "Modified: / 06-03-1996 / 13:54:10 / cg"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4464
    "Modified: / 17-04-2012 / 21:01:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4465
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4466
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4467
expandSelectionUp
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4468
    |l t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4469
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4470
    selectionStartLine notNil ifTrue:[
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4471
        expandingTop == true ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4472
            selectionStartLine := (selectionStartLine - 1) max:1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4473
            l := selectionStartLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4474
        ] ifFalse:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4475
            selectionEndLine := (selectionEndLine - 1) max:0.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4476
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4477
            l := selectionEndLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4478
            (selectionEndLine < clickLine
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4479
            or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])])
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4480
            ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4481
                t := selectionStartLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4482
                selectionStartLine := selectionEndLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4483
                selectionEndLine := t.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4484
                t := selectionStartCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4485
                selectionStartCol := selectionEndCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4486
                selectionEndCol := t.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4487
                l := selectionStartLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4488
                expandingTop := true
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4489
            ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4490
        ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4491
        self validateNewSelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4492
        self setPrimarySelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4493
        self selectionChanged.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4494
        "/ self redrawLine:l.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4495
        "/ self redrawLine:l+1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4496
        self redrawFromLine:l to:l+1.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4497
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4498
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4499
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4500
    "Modified: / 06-03-1996 / 14:12:06 / cg"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4501
    "Modified: / 17-04-2012 / 21:01:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4502
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4503
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4504
hasSelection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4505
    "return true, if there is a selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4506
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4507
    ^ selectionStartLine notNil
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4508
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4509
2350
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4510
hasSelectionForCopy
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4511
    "return true, if there is a selection which can be copyied
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4512
     (the same as #hasSelection, except for editfields in password-mode)"
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4513
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4514
    ^ self hasSelection
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4515
!
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4516
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4517
hasSelectionWithinSingleLine
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4518
    "return true, if there is a selection and it is within a line"
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4519
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4520
    ^ selectionStartLine notNil
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4521
      and:[ selectionStartLine == selectionEndLine ]
3315
1b42d2f8dcbc CRLF management
fm
parents: 3308
diff changeset
  4522
1b42d2f8dcbc CRLF management
fm
parents: 3308
diff changeset
  4523
    "Modified: / 04-07-2006 / 18:42:59 / fm"
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4524
!
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4525
5004
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4526
hasSingleFullLineSelected
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4527
    ^ (selectionStartLine notNil 
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4528
      and:[selectionEndLine notNil
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4529
      and:[selectionEndLine == (selectionStartLine+1)  
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4530
      and:[selectionStartCol == 1
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4531
      and:[selectionEndCol == 0
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4532
    ]]]])
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4533
!
08314fa44f18 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
  4534
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  4535
isInSelection:line col:aColNr
96256221e3af support drag
ca
parents: 2581
diff changeset
  4536
    "returns true, if the line, and column is in the selection
96256221e3af support drag
ca
parents: 2581
diff changeset
  4537
    "
3438
d83030fd5005 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3426
diff changeset
  4538
    selectionStartLine isNil ifTrue:[^ false].
d83030fd5005 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3426
diff changeset
  4539
    selectionEndLine   isNil ifTrue:[^ false].
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  4540
96256221e3af support drag
ca
parents: 2581
diff changeset
  4541
    (line between:selectionStartLine and:selectionEndLine) ifFalse:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4542
	^ false
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  4543
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  4544
96256221e3af support drag
ca
parents: 2581
diff changeset
  4545
    line == selectionStartLine ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4546
	aColNr < selectionStartCol ifTrue:[^ false]
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  4547
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  4548
96256221e3af support drag
ca
parents: 2581
diff changeset
  4549
    line == selectionEndLine ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4550
	(selectionEndCol ~~ 0 and:[selectionEndCol < aColNr]) ifTrue:[^ false]
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  4551
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  4552
    ^ true
96256221e3af support drag
ca
parents: 2581
diff changeset
  4553
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  4554
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4555
makeSelectionVisible
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4556
    "scroll to make the selection visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4557
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4558
    |line col|
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4559
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4560
    selectionStartLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4561
	expandingTop == true ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4562
	    line := selectionStartLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4563
	    col := selectionStartCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4564
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4565
	    line := selectionEndLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4566
	    col := selectionEndCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4567
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4568
	self makeLineVisible:line.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4569
	self makeColVisible:col inLine:line.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4570
    ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4571
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4572
    "Modified: 6.3.1996 / 13:53:45 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4573
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4574
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4575
selectAll
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4576
    "select the whole text"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4577
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4578
    self selectFromLine:1 col:1 toLine:(list size + 1) col:0
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4579
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4580
4140
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4581
selectFromCharacterPosition:pos1
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4582
    "compute line/col from the character position and select the text up to the end"
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4583
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4584
    |line1 col1 line2 col2|
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4585
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4586
    line1 := self lineOfCharacterPosition:pos1.
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4587
    col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1.
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4588
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4589
    line2 := (list size + 1).
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4590
    col2 := 0.
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4591
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4592
!
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4593
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4594
selectFromCharacterPosition:pos1 to:pos2
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4595
    "compute line/col from character positions and select the text"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4596
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4597
    |line1 col1 line2 col2|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4598
4554
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
  4599
    pos1 > pos2 ifTrue:[
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
  4600
        ^ self unselect
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
  4601
    ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4602
    line1 := self lineOfCharacterPosition:pos1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4603
    col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1.
4554
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
  4604
    col1 < 1 ifTrue:[ col1 := 1 ].
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
  4605
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4606
    line2 := self lineOfCharacterPosition:pos2.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4607
    col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1.
4554
18662f9c1792 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
  4608
    col2 < 1 ifTrue:[ col2 := 1 ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4609
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4610
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4611
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4612
selectFromLine:startLine col:startCol toLine:endLine col:endCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4613
    "select a piece of text and redraw that area"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4614
5046
bcbf8cb1b3d1 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5010
diff changeset
  4615
    ((selectionStartLine = startLine)
bcbf8cb1b3d1 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5010
diff changeset
  4616
      and:[ (selectionStartCol = startCol)
bcbf8cb1b3d1 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5010
diff changeset
  4617
      and:[ (selectionEndLine = endLine)
bcbf8cb1b3d1 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5010
diff changeset
  4618
      and:[ (selectionEndCol = endCol) ]]]) ifTrue:[^ self ].
bcbf8cb1b3d1 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5010
diff changeset
  4619
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4620
    self unselect.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4621
    startLine notNil ifTrue:[
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4622
        "new:"
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4623
        endLine < startLine ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4624
            ^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4625
        ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4626
        (endLine == startLine and:[endCol < startCol]) ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4627
            endCol ~~ 0 ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4628
                self selectFromLine:endLine col:endCol toLine:startLine col:startCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4629
            ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4630
            ^ self
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4631
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4632
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4633
" old:
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4634
        endLine < startLine ifTrue:[^ self].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4635
        (startLine == endLine and:[endCol < startCol]) ifTrue:[^ self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4636
"
4787
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4637
        selectionStartLine := startLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4638
        selectionStartCol := startCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4639
        selectionEndLine := endLine.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4640
        selectionEndCol := endCol.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4641
        self validateNewSelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4642
        self setPrimarySelection.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4643
        self selectionChanged.
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4644
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4645
        (selectionStartLine == selectionEndLine) ifTrue:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4646
            self redrawLine:selectionStartLine from:selectionStartCol to:selectionEndCol
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4647
        ] ifFalse:[
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4648
            selectionStartLine to:selectionEndLine do:[:lineNr |
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4649
                self redrawLine:lineNr
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4650
            ]
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4651
        ].
cc11ec8d6855 class: TextView
Claus Gittinger <cg@exept.de>
parents: 4785
diff changeset
  4652
        selectStyle := nil.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4653
    ]
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4654
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4655
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4656
     |v|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4657
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4658
     v := TextView extent:300@300.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4659
     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
  4660
     v openAndWait.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4661
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4662
     Delay waitForSeconds:1.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4663
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4664
     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
  4665
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4666
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4667
    "Modified: / 02-01-1997 / 13:32:25 / cg"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4668
    "Modified: / 17-04-2012 / 21:00:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4669
!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4670
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4671
selectFromLine:startLine toLine:endLine
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4672
    "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
  4673
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4674
    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
  4675
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4676
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4677
     |v|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4678
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4679
     v := TextView extent:300@300.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4680
     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
  4681
     v openAndWait.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4682
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4683
     Delay waitForSeconds:1.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4684
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4685
     v selectFromLine:2 toLine:10
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4686
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4687
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4688
    "Modified: 29.4.1996 / 12:23:46 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4689
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4690
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4691
selectLine:selectLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4692
    "select one line and redraw it"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4693
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4694
    self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4695
    wordStartCol := selectionStartCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4696
    wordEndCol := selectionEndCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4697
    wordStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4698
    wordEndLine := selectionEndLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4699
    selectStyle := #line
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4700
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4701
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4702
selectLineAtY:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4703
    "select the line at given y-(view-)coordinate"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4704
2413
2a72970c1da8 use #lineAtY:
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
  4705
    |selectLine|
2a72970c1da8 use #lineAtY:
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
  4706
2a72970c1da8 use #lineAtY:
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
  4707
    selectLine := self lineAtY:y. "/ self visibleLineToListLine:(self visibleLineOfY:y).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4708
    selectLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4709
	self selectLine:selectLine
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4710
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4711
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4712
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4713
selectLineWhereCharacterPosition:pos
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4714
    "select the line, where characterPosition pos is living.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4715
     The argument pos starts at 1 from the start of the text
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4716
     and counts characters (i.e. can be used to convert from
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4717
     character position within a string to line-position in view)."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4718
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4719
    self selectLine:(self lineOfCharacterPosition:pos)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4720
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4721
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4722
selectWordAtLine:line col:col
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4723
    "select the word at given line/col"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4724
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4725
    self
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4726
	wordAtLine:line col:col do:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4727
	    :beginLine :beginCol :endLine :endCol :style |
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4728
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4729
	    self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4730
	    selectStyle := style
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4731
	]
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  4732
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  4733
    "Modified: 18.3.1996 / 17:30:38 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4734
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4735
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4736
selectWordAtX:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4737
    "select the word at given x/y-(view-)coordinate"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4738
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4739
    |selectVisibleLine selectLine selectCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4740
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4741
    selectStyle := nil.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4742
    selectVisibleLine := self visibleLineOfY:y.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4743
    selectLine := self visibleLineToListLine:selectVisibleLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4744
    selectLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4745
	selectCol := self colOfX:x inVisibleLine:selectVisibleLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4746
	self selectWordAtLine:selectLine col:selectCol
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4747
    ]
1661
bf446f457d95 fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4748
bf446f457d95 fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4749
    "Modified: / 8.9.1998 / 21:22:46 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4750
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4751
3528
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4752
selectedInterval
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4753
    "return the selection-boundaries as interval"
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4754
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4755
    ^ self selectionStartIndex to:(self selectionStopIndex - 1)
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4756
!
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4757
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4758
selection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4759
    "return the selection as a collection of (line-)strings.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4760
     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
  4761
     collection will be an empty string."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4762
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4763
    |sel|
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4764
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4765
    selectionStartLine isNil ifTrue:[^ nil].
4466
5c7a01426564 changed: #selection
Claus Gittinger <cg@exept.de>
parents: 4462
diff changeset
  4766
    sel := self textFromLine:selectionStartLine col:(selectionStartCol max:1) toLine:selectionEndLine col:selectionEndCol.
3298
cf51bd945909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3292
diff changeset
  4767
    sel notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4768
	(characterEncoding ? #'iso10646-1' "eg unicode") ~~ #'iso10646-1' ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4769
	    sel := sel encodeFrom:characterEncoding into:#'iso10646-1'
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4770
	].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4771
    ].
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4772
    ^ sel
2158
1fbe3297506f generalized text-access fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents: 2120
diff changeset
  4773
4361
646cd7c5513e comment/format in: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents: 4321
diff changeset
  4774
    "Modified (comment): / 25-01-2012 / 00:29:09 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4775
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4776
2217
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4777
selectionAsString
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4778
    "return the selection as a String (i.e. without emphasis)"
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4779
2693
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  4780
    |sel|
2217
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4781
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4782
    (sel := self selection) isNil ifTrue:[^ nil].
2419
2ae3350454bc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2415
diff changeset
  4783
    sel := sel collect:[:each| each isNil ifTrue:[nil] ifFalse:[each string]].
2217
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4784
    ^ (sel asStringWithCRsFrom:1 to:(sel size) compressTabs:false withCR:false) string
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4785
!
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4786
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4787
selectionChanged
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4788
    "can be redefined for notification or special actions"
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4789
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4790
    "Modified: / 17-04-2012 / 20:59:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4791
!
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4792
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4793
selectionEndCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4794
    ^ selectionEndCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4795
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4796
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4797
selectionEndLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4798
    ^ selectionEndLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4799
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4800
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4801
selectionStartCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4802
    ^ selectionStartCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4803
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4804
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4805
selectionStartLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4806
    ^ selectionStartLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4807
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4808
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4809
setPrimarySelection
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4810
    "can be redefined for notification or special actions"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4811
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4812
    device notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4813
	"On X11, be nice and set the PRIMARY selection.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4814
	 (#setPrimaryText:ownerView: is void in DeviceWorkstation)"
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4815
	device setPrimaryText: self selectionAsString ownerView: self.
4419
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4816
    ].
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4817
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4818
    "Created: / 17-04-2012 / 20:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4819
!
a7436b36c0a0 added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4409
diff changeset
  4820
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4821
st80SelectMode
3459
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4822
    st80SelectMode notNil ifTrue:[^ st80SelectMode].
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4823
    ^ self class st80SelectMode
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4824
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4825
    "Created: / 03-07-2006 / 16:30:59 / cg"
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4826
!
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4827
3459
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4828
st80SelectMode:aBoolean
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4829
    st80SelectMode := aBoolean
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4830
!
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4831
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4832
unselect
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4833
    "unselect - if there was a selection redraw that area"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4834
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4835
    |startLine endLine startVisLine endVisLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4836
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4837
    selectionStartLine notNil ifTrue:[
4500
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4838
	startLine := selectionStartLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4839
	endLine := selectionEndLine.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4840
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4841
	self unselectWithoutRedraw.
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4842
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4843
	"/ if the selection is not visible, we are done
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4844
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4845
	startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4846
	endLine < firstLineShown ifTrue:[^ self].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4847
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4848
	startLine < firstLineShown ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4849
	    startVisLine := 1
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4850
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4851
	    startVisLine := self listLineToVisibleLine:startLine
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4852
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4853
	endLine >= (firstLineShown + nLinesShown) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4854
	    endVisLine := nLinesShown
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4855
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4856
	    endVisLine := self listLineToVisibleLine:endLine
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4857
	].
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4858
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4859
	"/ if its only part of a line, just redraw what has to be
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4860
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4861
	(startLine == endLine) ifTrue:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4862
	    super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4863
	] ifFalse:[
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4864
	    self redrawFromVisibleLine:startVisLine to:endVisLine
1fe68567471d resizehandle
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
  4865
	].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4866
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4867
    selectStyle := nil
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  4868
715
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  4869
    "Modified: 29.5.1996 / 14:54:11 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4870
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4871
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4872
unselectWithoutRedraw
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4873
    "forget selection but do not redraw the selection area
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4874
     - 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
  4875
     known to be invisible (however, redraw knows about that anyway)."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4876
2735
5ba2010aefa4 *** empty log message ***
penk
parents: 2730
diff changeset
  4877
    selectionStartLine := selectionEndLine := nil.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4878
    self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4879
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4880
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4881
validateNewSelection
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4882
     "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
  4883
      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
  4884
      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
  4885
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4886
    ^ self
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  4887
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4888
    "Modified: 29.4.1996 / 12:32:08 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4889
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4890
4310
ff92dd203d7e category of: #isTextView
Claus Gittinger <cg@exept.de>
parents: 4255
diff changeset
  4891
!TextView methodsFor:'testing'!
ff92dd203d7e category of: #isTextView
Claus Gittinger <cg@exept.de>
parents: 4255
diff changeset
  4892
ff92dd203d7e category of: #isTextView
Claus Gittinger <cg@exept.de>
parents: 4255
diff changeset
  4893
isTextView
ff92dd203d7e category of: #isTextView
Claus Gittinger <cg@exept.de>
parents: 4255
diff changeset
  4894
    "I am showing text"
ff92dd203d7e category of: #isTextView
Claus Gittinger <cg@exept.de>
parents: 4255
diff changeset
  4895
ff92dd203d7e category of: #isTextView
Claus Gittinger <cg@exept.de>
parents: 4255
diff changeset
  4896
    ^ true
ff92dd203d7e category of: #isTextView
Claus Gittinger <cg@exept.de>
parents: 4255
diff changeset
  4897
! !
ff92dd203d7e category of: #isTextView
Claus Gittinger <cg@exept.de>
parents: 4255
diff changeset
  4898
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4899
!TextView class methodsFor:'documentation'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4900
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4901
version
5099
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  4902
    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.382 2014-07-08 21:39:46 cg Exp $'
3964
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
  4903
!
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
  4904
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
  4905
version_CVS
5099
1af2798f1150 class: TextView
Claus Gittinger <cg@exept.de>
parents: 5094
diff changeset
  4906
    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.382 2014-07-08 21:39:46 cg Exp $'
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4907
! !
2630
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
  4908
4485
758e9ff26eda class: TextView
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
  4909
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  4910
TextView initialize!