gizak / termui

Golang terminal dashboard
MIT License
13.23k stars 786 forks source link

how to change InnerWidth #187

Closed chyroc closed 5 years ago

chyroc commented 6 years ago

the default value(or not-terminal env value) of InnerWidth() is 0, so for code :

func (r *Input) cursorIndex() int {
    return (r.Par.InnerWidth()+1)*r.cursorRowIndex + r.cursorColIndex
}

a unit test for my cursorIndex and other *Par component method not work,

how to do ? or there is a better way than modify InnerWidth

chyroc commented 6 years ago

i search the issues, and only find a https://github.com/gizak/termui/issues/23 for make inner getter public, not find a way to modify it

cjbassi commented 5 years ago

Inner is now a public field as of 958a28575d7411492d25e42da3ad5a6e5947d9a4, so you should be able to modify it. InnerWidth has also been replaced with Inner.Dx(). Do note that a lot of breaking changes have been introduced in that commit, just btw.

Also, Inner is automatically updated in calls to SetRect, which is used to position and size widgets now. And SetRect is used by Grids to update widget sizes. Just some things to be aware of.