diff options
Diffstat (limited to 'place.go')
| -rw-r--r-- | place.go | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -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 + } +} |
