From ee0f84fd8ef5993a6c374c8ee4e22c837ca39d97 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 2 Feb 2024 14:49:17 -0600 Subject: finds the item chosen from the dropdown list Signed-off-by: Jeff Carr --- place.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'place.go') diff --git a/place.go b/place.go index 726e8ed..1ef1775 100644 --- a/place.go +++ b/place.go @@ -214,3 +214,53 @@ func textSize(n *tree.Node) (int, int) { } return width, height } + +// moves the gocui view the W and H offset on the screen +/* + gocui defines the offset like this: + + width -> increases to the right + ---------------------------------- hieght + | H = 1 | increases + | | | + | W = 1 W = 18 | | + | | v + | H = 5 | downwards + ------------------------------------- +*/ +// change over to this name +func (tk *guiWidget) MoveToOffset(W, H int) { + tk.gocuiSetWH(W, H) +} + +// returns where the corner of widget starts (upper left) +func (tk *guiWidget) Position() (int, int) { + return tk.gocuiSize.w0, tk.gocuiSize.h0 +} + +func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) { + w := len(widget.GetString(tk.value)) + lines := strings.Split(widget.GetString(tk.value), "\n") + h := len(lines) + + // tk := n.tk + if tk.isFake { + tk.gocuiSize.w0 = sizeW + tk.gocuiSize.h0 = sizeH + tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW + tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH + return + } + + if tk.frame { + tk.gocuiSize.w0 = sizeW + tk.gocuiSize.h0 = sizeH + tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW + tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH + } else { + tk.gocuiSize.w0 = sizeW - 1 + tk.gocuiSize.h0 = sizeH - 1 + tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + 1 + tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + 1 + } +} -- cgit v1.2.3