@@ -73,28 +73,28 @@ func (h *BufPane) MousePress(e *tcell.EventMouse) bool {
7373 h .Cursor .Loc = mouseLoc
7474 }
7575 if time .Since (h .lastClickTime )/ time .Millisecond < config .DoubleClickThreshold && (mouseLoc .X == h .lastLoc .X && mouseLoc .Y == h .lastLoc .Y ) {
76- if h .doubleClick {
76+ if h .DoubleClick {
7777 // Triple click
7878 h .lastClickTime = time .Now ()
7979
80- h .tripleClick = true
81- h .doubleClick = false
80+ h .TripleClick = true
81+ h .DoubleClick = false
8282
8383 h .Cursor .SelectLine ()
8484 h .Cursor .CopySelection (clipboard .PrimaryReg )
8585 } else {
8686 // Double click
8787 h .lastClickTime = time .Now ()
8888
89- h .doubleClick = true
90- h .tripleClick = false
89+ h .DoubleClick = true
90+ h .TripleClick = false
9191
9292 h .Cursor .SelectWord ()
9393 h .Cursor .CopySelection (clipboard .PrimaryReg )
9494 }
9595 } else {
96- h .doubleClick = false
97- h .tripleClick = false
96+ h .DoubleClick = false
97+ h .TripleClick = false
9898 h .lastClickTime = time .Now ()
9999
100100 h .Cursor .OrigSelection [0 ] = h .Cursor .Loc
@@ -116,9 +116,9 @@ func (h *BufPane) MouseDrag(e *tcell.EventMouse) bool {
116116 }
117117 h .Cursor .Loc = h .LocFromVisual (buffer.Loc {mx , my })
118118
119- if h .tripleClick {
119+ if h .TripleClick {
120120 h .Cursor .AddLineToSelection ()
121- } else if h .doubleClick {
121+ } else if h .DoubleClick {
122122 h .Cursor .AddWordToSelection ()
123123 } else {
124124 h .Cursor .SelectTo (h .Cursor .Loc )
@@ -135,7 +135,7 @@ func (h *BufPane) MouseRelease(e *tcell.EventMouse) bool {
135135 // that doesn't support mouse motion events. But when the mouse click is
136136 // within the scroll margin, that would cause a scroll and selection
137137 // even for a simple mouse click, which is not good.
138- // if !h.doubleClick && !h.tripleClick {
138+ // if !h.DoubleClick && !h.TripleClick {
139139 // mx, my := e.Position()
140140 // h.Cursor.Loc = h.LocFromVisual(buffer.Loc{mx, my})
141141 // h.Cursor.SetSelectionEnd(h.Cursor.Loc)
@@ -153,7 +153,7 @@ func (h *BufPane) ScrollUpAction() bool {
153153 return true
154154}
155155
156- // ScrollDownAction scrolls the view up
156+ // ScrollDownAction scrolls the view down
157157func (h * BufPane ) ScrollDownAction () bool {
158158 h .ScrollDown (util .IntOpt (h .Buf .Settings ["scrollspeed" ]))
159159 return true
@@ -1925,30 +1925,29 @@ func (h *BufPane) ForceQuit() bool {
19251925 return true
19261926}
19271927
1928- // Quit this will close the current tab or view that is open
1929- func ( h * BufPane ) Quit () bool {
1930- if h . Buf . Modified ( ) {
1931- for _ , b := range buffer . OpenBuffers {
1932- if b != h . Buf && b . SharedBuffer == h . Buf . SharedBuffer {
1933- h . ForceQuit ()
1934- return true
1935- }
1928+ // closePrompt displays a prompt to save the buffer before closing it to proceed
1929+ // with a different action or command
1930+ func ( h * BufPane ) closePrompt ( action string , callback func () ) {
1931+ InfoBar . YNPrompt ( "Save changes to " + h . Buf . GetName () + " before closing? (y,n,esc)" , func ( yes , canceled bool ) {
1932+ if ! canceled && ! yes {
1933+ callback ()
1934+ } else if ! canceled && yes {
1935+ h . SaveCB ( action , callback )
19361936 }
1937+ })
1938+ }
19371939
1940+ // Quit this will close the current tab or view that is open
1941+ func (h * BufPane ) Quit () bool {
1942+ if h .Buf .Modified () && ! h .Buf .Shared () {
19381943 if config .GlobalSettings ["autosave" ].(float64 ) > 0 && h .Buf .Path != "" {
19391944 // autosave on means we automatically save when quitting
19401945 h .SaveCB ("Quit" , func () {
19411946 h .ForceQuit ()
19421947 })
19431948 } else {
1944- InfoBar .YNPrompt ("Save changes to " + h .Buf .GetName ()+ " before closing? (y,n,esc)" , func (yes , canceled bool ) {
1945- if ! canceled && ! yes {
1946- h .ForceQuit ()
1947- } else if ! canceled && yes {
1948- h .SaveCB ("Quit" , func () {
1949- h .ForceQuit ()
1950- })
1951- }
1949+ h .closePrompt ("Quit" , func () {
1950+ h .ForceQuit ()
19521951 })
19531952 }
19541953 } else {
0 commit comments