@@ -62,7 +62,7 @@ public HashSet<int> Start(ApplicationData applicationData)
6262 AddListView ( win ) ;
6363
6464 // Status bar is where our key-bindings are handled
65- AddStatusBar ( ! _applicationData . MinUI ) ;
65+ AddStatusBar ( ) ;
6666
6767 // If -Filter parameter is set, apply it.
6868 ApplyFilter ( ) ;
@@ -117,7 +117,8 @@ private GridViewDataSource LoadData()
117117 return new GridViewDataSource ( items ) ;
118118 }
119119
120- private void ApplyFilter ( ) {
120+ private void ApplyFilter ( )
121+ {
121122 List < GridViewRow > itemList = GridViewHelpers . FilterData ( _itemSource . GridViewRowList , _applicationData . Filter ?? string . Empty ) ;
122123 // Set the ListView to show only the subset defined by the filter
123124 _listView . Source = new GridViewDataSource ( itemList ) ;
@@ -146,50 +147,72 @@ private Window CreateTopLevelWindow()
146147 Width = Dim . Fill ( _applicationData . MinUI ? - 1 : 0 ) ,
147148 Height = Dim . Fill ( _applicationData . MinUI ? - 1 : 1 )
148149 } ;
149-
150- if ( _applicationData . MinUI ) {
150+
151+ if ( _applicationData . MinUI )
152+ {
151153 win . Border . BorderStyle = BorderStyle . None ;
152- }
153-
154+ }
155+
154156 Application . Top . Add ( win ) ;
155157 return win ;
156158 }
157159
158160 private void AddStatusBar ( bool visible )
159161 {
160- var statusBar = new StatusBar (
161- _applicationData . OutputMode != OutputModeOption . None
162- ? new StatusItem [ ]
162+ var statusItems = new List < StatusItem > ( ) ;
163+ if ( _applicationData . OutputMode != OutputModeOption . None )
164+ {
165+ // Use Key.Unknown for SPACE with no delegate because ListView already
166+ // handles SPACE
167+ statusItems . Add ( new StatusItem ( Key . Unknown , "~SPACE~ Select Item" , null ) ) ;
168+ }
169+
170+ if ( _applicationData . OutputMode == OutputModeOption . Multiple )
171+ {
172+ statusItems . Add ( new StatusItem ( Key . A | Key . CtrlMask , "~^A~ Select All" , ( ) =>
173+ {
174+ // This selects only the items that match the Filter
175+ var gvds = _listView . Source as GridViewDataSource ;
176+ gvds . GridViewRowList . ForEach ( i => i . IsMarked = true ) ;
177+ _listView . SetNeedsDisplay ( ) ;
178+ } ) ) ;
179+
180+ // Use Ctrl-N until Terminal.Gui supports ctrl-shift chords
181+ statusItems . Add ( new StatusItem ( Key . N | Key . CtrlMask , "~^N~ Select None" , ( ) =>
182+ {
183+ // This un-selects only the items that match the Filter
184+ var gvds = _listView . Source as GridViewDataSource ;
185+ gvds . GridViewRowList . ForEach ( i => i . IsMarked = false ) ;
186+ _listView . SetNeedsDisplay ( ) ;
187+ } ) ) ;
188+ }
189+
190+ if ( _applicationData . OutputMode != OutputModeOption . None )
191+ {
192+ statusItems . Add ( new StatusItem ( Key . Enter , "~ENTER~ Accept" , ( ) =>
193+ {
194+ if ( Application . Top . MostFocused == _listView )
163195 {
164- // Use Key.Unknown for SPACE with no delegate because ListView already
165- // handles SPACE
166- new StatusItem ( Key . Unknown , "~SPACE~ Mark Item" , null ) ,
167- new StatusItem ( Key . Enter , "~ENTER~ Accept" , ( ) =>
196+ // If nothing was explicitly marked, we return the item that was selected
197+ // when ENTER is pressed in Single mode. If something was previously selected
198+ // (using SPACE) then honor that as the single item to return
199+ if ( _applicationData . OutputMode == OutputModeOption . Single &&
200+ _itemSource . GridViewRowList . Find ( i => i . IsMarked ) == null )
168201 {
169- if ( Application . Top . MostFocused == _listView )
170- {
171- // If nothing was explicitly marked, we return the item that was selected
172- // when ENTER is pressed in Single mode. If something was previously selected
173- // (using SPACE) then honor that as the single item to return
174- if ( _applicationData . OutputMode == OutputModeOption . Single &&
175- _itemSource . GridViewRowList . Find ( i => i . IsMarked ) == null )
176- {
177- _listView . MarkUnmarkRow ( ) ;
178- }
179- Accept ( ) ;
180- }
181- else if ( Application . Top . MostFocused == _filterField )
182- {
183- _listView . SetFocus ( ) ;
184- }
185- } ) ,
186- new StatusItem ( Key . Esc , "~ESC~ Close" , ( ) => Close ( ) )
202+ _listView . MarkUnmarkRow ( ) ;
203+ }
204+ Accept ( ) ;
187205 }
188- : new StatusItem [ ]
206+ else if ( Application . Top . MostFocused == _filterField )
189207 {
190- new StatusItem ( Key . Esc , "~ESC~ Close" , ( ) => Close ( ) )
208+ _listView . SetFocus ( ) ;
191209 }
192- ) ;
210+ } ) ) ;
211+ }
212+
213+ statusItems . Add ( new StatusItem ( Key . Esc , "~ESC~ Close" , ( ) => Close ( ) ) ) ;
214+
215+ var statusBar = new StatusBar ( statusItems . ToArray ( ) ) ;
193216 statusBar . Visible = visible ;
194217 Application . Top . Add ( statusBar ) ;
195218 }
@@ -324,7 +347,8 @@ private void AddHeaders(Window win, List<string> gridHeaders)
324347 }
325348 }
326349
327- if ( ! _applicationData . MinUI ) {
350+ if ( ! _applicationData . MinUI )
351+ {
328352 var headerLine = new Label ( headerLineText . ToString ( ) )
329353 {
330354 X = 0 ,
@@ -341,7 +365,7 @@ private void AddListView(Window win)
341365 if ( ! _applicationData . MinUI )
342366 {
343367 _listView . Y = Pos . Bottom ( _filterLabel ) + 3 ; // 1 for space, 1 for header, 1 for header underline
344- }
368+ }
345369 else
346370 {
347371 _listView . Y = 1 ; // 1 for space, 1 for header, 1 for header underline
0 commit comments