Skip to content

Commit

Permalink
When capinfo is opened, put focus on the Close button
Browse files Browse the repository at this point in the history
I expect the user will typically want to look then close, so this is
more streamlined. However, if the user navigates up so that they can
enter copy-mode and copy the capinfos data, I now use a "slim" frame
widget around the capinfos text to indicate that there is something
there that can be selected and copied.
  • Loading branch information
gcla committed Sep 10, 2021
1 parent bc700cd commit df4d2aa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ui/dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/gcla/gowid/widgets/text"
"github.com/gcla/termshark/v2"
"github.com/gcla/termshark/v2/widgets/appkeys"
"github.com/gcla/termshark/v2/widgets/framefocus"
"github.com/gcla/termshark/v2/widgets/minibuffer"
"github.com/gcla/termshark/v2/widgets/scrollabletext"
"github.com/gcla/termshark/v2/widgets/withscrollbar"
Expand Down Expand Up @@ -65,7 +66,7 @@ func OpenMessageForCopy(msgt string, openOver gowid.ISettableComposite, app gowi
return openMessage(msgt, openOver, true, false, app)
}

func openMessage(msgt string, openOver gowid.ISettableComposite, focusOnWidget bool, doFlow bool, app gowid.IApp) *dialog.Widget {
func openMessage(msgt string, openOver gowid.ISettableComposite, selectableWidget bool, doFlow bool, app gowid.IApp) *dialog.Widget {
var dh gowid.IWidgetDimension = fixed
var dw gowid.IWidgetDimension = fixed

Expand All @@ -86,14 +87,20 @@ func openMessage(msgt string, openOver gowid.ISettableComposite, focusOnWidget b
},
)

view = selectable.New(view)
if selectableWidget {
view = selectable.New(view)
}

view = hpadding.New(
view,
hmiddle,
dh,
)

if selectableWidget {
view = framefocus.NewSlim(view)
}

view = framed.NewSpace(view)

YesNo = dialog.New(
Expand All @@ -104,7 +111,6 @@ func openMessage(msgt string, openOver gowid.ISettableComposite, focusOnWidget b
BackgroundStyle: gowid.MakePaletteRef("dialog"),
BorderStyle: gowid.MakePaletteRef("dialog"),
ButtonStyle: gowid.MakePaletteRef("dialog-button"),
FocusOnWidget: focusOnWidget,
Modal: true,
},
)
Expand Down

0 comments on commit df4d2aa

Please sign in to comment.