fork/gdu
git clone https://git.julia.blue/fork/gdu
9ca5c60
subvolume
1package tui 2 3import ( 4"time" 5 6"github.com/dundee/gdu/v5/pkg/fs" 7"github.com/gdamore/tcell/v2" 8"github.com/rivo/tview" 9) 10 11func (ui * UI )onMouse (event * tcell.EventMouse ,action tview.MouseAction ) (* tcell.EventMouse , tview.MouseAction ) { 12if event == nil { 13return nil ,action 14 } 15 16if ui .pages .HasPage ("confirm" )|| 17ui .pages .HasPage ("progress" )|| 18ui .pages .HasPage ("deleting" )|| 19ui .pages .HasPage ("emptying" )|| 20ui .pages .HasPage ("moving to trash" )|| 21ui .pages .HasPage ("help" ) { 22return nil ,action 23 } 24 25// nolint: exhaustive // Why: we don't need to handle all mouse events 26switch action { 27case tview .MouseLeftDoubleClick : 28row ,column := ui .table .GetSelection () 29if ui .currentDirPath != ui .topDirPath && row == 0 { 30ui .handleLeft () 31 }else { 32selectedFile := ui .table .GetCell (row ,column ).GetReference ().(fs.Item ) 33if selectedFile .IsDir () { 34ui .handleRight () 35 }else { 36if ui .noViewFile { 37previousHeaderText := ui .header .GetText (false ) 38 39ui .header .SetText (" Viewing files is disabled!" ) 40 41go func () { 42time .Sleep (2 * time .Second ) 43ui .app .QueueUpdateDraw (func () { 44ui .header .Clear () 45ui .header .SetText (previousHeaderText ) 46 }) 47 }() 48 49return nil ,action 50 } 51ui .showFile () 52 } 53 } 54return nil ,action 55case tview .MouseScrollUp ,tview .MouseScrollDown : 56row ,column := ui .table .GetSelection () 57if action == tview .MouseScrollUp && row > 0 { 58row -- 59 }else if action == tview .MouseScrollDown && row + 1 < ui .table .GetRowCount () { 60row ++ 61 } 62ui .table .Select (row ,column ) 63return nil ,action 64 } 65 66return event ,action 67}