Visual Mode can now be disabled

This commit is contained in:
aditya-K2
2023-04-13 03:54:50 +05:30
parent 4adf71a1b4
commit d6142372a1

View File

@@ -22,10 +22,11 @@ type _range struct {
}
type interactiveView struct {
visual bool
vrange *_range
baseSel int
Table *tview.Table
visual bool
disableVisual bool
vrange *_range
baseSel int
Table *tview.Table
}
func NewInteractiveView() *interactiveView {
@@ -48,6 +49,10 @@ func NewInteractiveView() *interactiveView {
return i
}
func (i *interactiveView) DisableVisualMode(disable bool) {
i.disableVisual = disable
}
func (i *interactiveView) SelectionHandler(selrow int) {
if i.visual {
i.toggleVisualMode()
@@ -181,7 +186,9 @@ func (i *interactiveView) capture(e *tcell.EventKey) *tcell.EventKey {
}
case 'v':
{
i.toggleVisualMode()
if !i.disableVisual {
i.toggleVisualMode()
}
return nil
}
case 'g':
@@ -199,7 +206,9 @@ func (i *interactiveView) capture(e *tcell.EventKey) *tcell.EventKey {
default:
{
if e.Key() == tcell.KeyEscape {
return i.getHandler("exitvisual")(e)
if !i.disableVisual {
return i.getHandler("exitvisual")(e)
}
} else if GetCurrentView().ExternalInputCapture() != nil {
return GetCurrentView().ExternalInputCapture()(e)
}