@@ -189,6 +189,12 @@ func (p *MangaPage) setHandlers(cancel context.CancelFunc) {
189
189
return event
190
190
})
191
191
192
+ p .Table .SetSelectionChangedFunc (func (row , _column int ) {
193
+ if p .sWrap .IsInVisualMode () {
194
+ p .selectRange (min (row , p .sWrap .VisualStart ), max (row , p .sWrap .VisualStart ))
195
+ }
196
+ })
197
+
192
198
// Set table selected function.
193
199
p .Table .SetSelectedFunc (func (row , _ int ) {
194
200
log .Println ("Creating and showing confirm download modal..." )
@@ -203,16 +209,26 @@ func (p *MangaPage) setHandlers(cancel context.CancelFunc) {
203
209
204
210
// Set table input captures.
205
211
p .Table .SetInputCapture (func (event * tcell.EventKey ) * tcell.EventKey {
212
+
206
213
switch event .Key () {
207
214
case tcell .KeyCtrlE : // User selects this manga row.
208
215
p .ctrlEInput ()
216
+ return event
209
217
case tcell .KeyCtrlA : // User wants to toggle select All.
210
218
p .ctrlAInput ()
219
+ return event
211
220
case tcell .KeyCtrlR : // User wants to toggle read status for Selection.
212
221
p .ctrlRInput ()
222
+ return event
213
223
case tcell .KeyCtrlQ :
214
224
p .ctrlQInput ()
225
+ return event
215
226
}
227
+
228
+ if event .Rune () == 'v' || event .Rune () == 'V' {
229
+ p .shiftVInput ()
230
+ }
231
+
216
232
return event
217
233
})
218
234
}
@@ -234,6 +250,51 @@ func (p *MangaPage) ctrlAInput() {
234
250
p .markAll ()
235
251
}
236
252
253
+ func (p * MangaPage ) selectRange (from , to int ) {
254
+ start := min (from , to )
255
+ end := max (from , to )
256
+
257
+ for row := 1 ; row < p .Table .GetRowCount (); row ++ {
258
+ if row < start || row > end {
259
+ if p .sWrap .HasSelection (row ) {
260
+ p .markUnselected (row )
261
+ }
262
+ } else {
263
+ if ! p .sWrap .HasSelection (row ) {
264
+ p .markSelected (row )
265
+ }
266
+ }
267
+ }
268
+ }
269
+
270
+ func min (a , b int ) int {
271
+ if a < b {
272
+ return a
273
+ }
274
+ return b
275
+ }
276
+
277
+ func max (a , b int ) int {
278
+ if a > b {
279
+ return a
280
+ }
281
+ return b
282
+ }
283
+
284
+ func (p * MangaPage ) shiftVInput () {
285
+ if p .sWrap .IsInVisualMode () {
286
+ p .sWrap .StopVisualSelection ()
287
+ for row := 1 ; row < p .Table .GetRowCount (); row ++ {
288
+ if p .sWrap .HasSelection (row ) {
289
+ p .markUnselected (row )
290
+ }
291
+ }
292
+ } else {
293
+ row , _ := p .Table .GetSelection ()
294
+ p .sWrap .StartVisualSelection (row )
295
+ }
296
+ }
297
+
237
298
// ctrlRInput : Allows user to toggle read status for a chapter.
238
299
func (p * MangaPage ) ctrlRInput () {
239
300
modal := confirmModal (utils .ToggleReadChapterModalID ,
0 commit comments