style and typo fixes

This commit is contained in:
Vladimir Markelov 2019-05-07 21:47:56 -07:00
parent 9e72c95fac
commit 17ae50e353
14 changed files with 66 additions and 60 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.*~
~*.*
*.swp
*.log
*.log
*.exe

View File

@ -70,7 +70,7 @@ type BarChart struct {
}
/*
NewBarChart creates a new bar chart.
CreateBarChart creates a new bar chart.
view - is a View that manages the control
parent - is container that keeps the control. The same View can be a view and a parent at the same time.
w and h - are minimal size of the control.
@ -105,7 +105,7 @@ func CreateBarChart(parent Control, w, h int, scale int) *BarChart {
return c
}
// Repaint draws the control on its View surface
// Draw repaints the control on its View surface
func (b *BarChart) Draw() {
if b.hidden {
return
@ -441,12 +441,12 @@ func (b *BarChart) SetAutoSize(auto bool) {
b.autosize = auto
}
// Gap returns width of visual gap between two adjacent bars
// BarGap returns width of visual gap between two adjacent bars
func (b *BarChart) BarGap() int32 {
return atomic.LoadInt32(&b.gap)
}
// SetGap sets the space width between two adjacent bars
// SetBarGap sets the space width between two adjacent bars
func (b *BarChart) SetBarGap(gap int32) {
atomic.StoreInt32(&b.gap, gap)
}

View File

@ -601,7 +601,7 @@ func (c *BaseControl) PlaceChildren() {
}
}
// ActiveColors return the attrubutes for the controls when it
// ActiveColors return the attributes for the controls when it
// is active: text and background colors
func (c *BaseControl) ActiveColors() (term.Attribute, term.Attribute) {
return c.fgActive, c.bgActive

View File

@ -1,5 +1,6 @@
2019-05-7 - version 1.2.0
[*] Changed default window close icon from "O" to "■"
[*] Doc comments clean up
2019-03-16 - version 1.1.0
[!] TextReader renamed to TextDisplay to avoid confusion with io.Reader. In

View File

@ -11,10 +11,9 @@ Content is scrollable with arrow keys or by clicking up and bottom buttons
on the scroll(now content is scrollable with mouse dragging only on Windows).
ListBox calls onSelectItem item function after a user changes currently
selected item with mouse or using keyboard (extra case: the event is emitted
when a user presses Enter - the case is used in ComboBox to select an item
from drop down list). Event structure has 2 fields filled: Y - selected
item number in list(-1 if nothing is selected), Msg - text of the selected item.
selected item with mouse or using keyboard. Event structure has 2 fields filled:
Y - selected item number in list(-1 if nothing is selected),
Msg - text of the selected item.
*/
type ListBox struct {
BaseControl
@ -29,10 +28,10 @@ type ListBox struct {
}
/*
NewListBox creates a new frame.
CreateListBox creates a new frame.
view - is a View that manages the control
parent - is container that keeps the control. The same View can be a view and a parent at the same time.
width and heigth - are minimal size of the control.
width and height - are minimal size of the control.
scale - the way of scaling the control when the parent is resized. Use DoNotScale constant if the
control should keep its original size.
*/
@ -110,7 +109,7 @@ func (l *ListBox) drawItems() {
}
}
// Repaint draws the control on its View surface
// Draw repaints the control on its View surface
func (l *ListBox) Draw() {
if l.hidden {
return

View File

@ -24,7 +24,7 @@ type ProgressBar struct {
}
/*
NewProgressBar creates a new ProgressBar.
CreateProgressBar creates a new ProgressBar.
parent - is container that keeps the control.
width and heigth - are minimal size of the control.
scale - the way of scaling the control when the parent is resized. Use DoNotScale constant if the
@ -58,7 +58,7 @@ func CreateProgressBar(parent Control, width, height int, scale int) *ProgressBa
return b
}
// Repaint draws the control on its View surface.
// Draw repaints the control on its View surface.
// Horizontal ProgressBar supports custom title over the bar.
// One can set title using method SetTitle. There are a few
// predefined variables that can be used inside title to

View File

@ -18,7 +18,7 @@ type Radio struct {
}
/*
NewRadio creates a new radio button.
CreateRadio creates a new radio button.
view - is a View that manages the control
parent - is container that keeps the control. The same View can be a view and a parent at the same time.
width - is minimal width of the control.
@ -51,7 +51,7 @@ func CreateRadio(parent Control, width int, title string, scale int) *Radio {
return c
}
// Repaint draws the control on its View surface
// Draw repaints the control on its View surface
func (c *Radio) Draw() {
if c.hidden {
return
@ -96,13 +96,13 @@ func (c *Radio) Draw() {
DrawText(x+4+shift, y, text)
}
/*
ProcessEvent processes all events come from the control parent. If a control
processes an event it should return true. If the method returns false it means
that the control do not want or cannot process the event and the caller sends
the event to the control parent.
The control processes only space button and mouse clicks to make control selected. Deselecting control is not possible: one has to click another radio of the radio group to deselect this button
*/
// ProcessEvent processes all events come from the control parent. If a control
// processes an event it should return true. If the method returns false it means
// that the control do not want or cannot process the event and the caller sends
// the event to the control parent.
// The control processes only space button and mouse clicks to make control selected.
// Deselecting control is not possible: one has to click another radio of the radio
// group to deselect this button
func (c *Radio) ProcessEvent(event Event) bool {
if (!c.Active() && event.Type == EventKey) || !c.Enabled() {
return false

View File

@ -7,7 +7,7 @@ type RadioGroup struct {
items []*Radio
}
// NewRadioGroup creates a new RadioGroup
// CreateRadioGroup creates a new RadioGroup
func CreateRadioGroup() *RadioGroup {
c := new(RadioGroup)
c.items = make([]*Radio, 0)
@ -66,7 +66,7 @@ func (c *RadioGroup) SetSelected(id int) bool {
return found
}
// AddItem add a new radio button to group
// AddItem adds a new radio button to group
func (c *RadioGroup) AddItem(r *Radio) {
c.items = append(c.items, r)
r.SetGroup(c)

View File

@ -11,12 +11,12 @@ SparkChart is a chart that represents a live data that
is continuously added to the chart. Or it can be static
element that displays predefined set of data - in this
case it looks like BarChart. At a moment SparkChart
keeps only th enumber of last data that is enough to
keeps only the number of last data that is enough to
fill the control area. So, if you enlarge the control,
it will show partially filled area until it gets new data.
SparkChart displays vertical axis with values on the chart left
if ValueWidth greater than 0, horizontal axis with bar titles.
Maximum peaks(maximum of the the data that control keeps)
Maximum peaks(maximum of the data that control keeps)
can be hilited with different color.
By default the data is autoscaled to make the highest bar
fit the full height of the control. But it maybe useful
@ -36,7 +36,7 @@ type SparkChart struct {
}
/*
NewSparkChart creates a new spark chart.
CreateSparkChart creates a new spark chart.
view - is a View that manages the control
parent - is container that keeps the control. The same View can be a view and a parent at the same time.
w and h - are minimal size of the control.
@ -71,7 +71,7 @@ func CreateSparkChart(parent Control, w, h int, scale int) *SparkChart {
return c
}
// Repaint draws the control on its View surface
// Draw repaints the control on its View surface
func (b *SparkChart) Draw() {
if b.hidden {
return
@ -239,7 +239,7 @@ func (b *SparkChart) ClearData() {
b.data = make([]float64, 0)
}
// SetData assign a new bar list to a chart
// SetData assigns a new bar list to a chart
func (b *SparkChart) SetData(data []float64) {
b.mtx.Lock()
defer b.mtx.Unlock()

View File

@ -124,7 +124,7 @@ type TableEvent struct {
}
/*
NewTableView creates a new frame.
CreateTableView creates a new frame.
view - is a View that manages the control
parent - is container that keeps the control. The same View can be a view and a parent at the same time.
width and height - are minimal size of the control.
@ -353,7 +353,7 @@ func (l *TableView) drawCells() {
}
}
// Repaint draws the control on its View surface
// Draw repaints the control on its View surface
func (l *TableView) Draw() {
if l.hidden {
return

View File

@ -87,7 +87,7 @@ func (l *TextDisplay) drawText() {
}
}
// Repaint draws the control on its View surface
// Draw repaints the control on its View surface
func (l *TextDisplay) Draw() {
if l.hidden {
return

View File

@ -15,7 +15,7 @@ added on the fly and if the autoscroll is enabled the control
scroll down to the end - it may be useful to create a log
viewer.
Content is scrollable with arrow keys or by clicking buttons
on the scrolls(a control can have upto 2 scrollbars: vertical
on the scrolls(a control can have up to 2 scrollbars: vertical
and horizontal. The latter one is available only if WordWrap
mode is off).
*/
@ -37,10 +37,10 @@ type TextView struct {
}
/*
NewTextView creates a new frame.
CreateTextView creates a new frame.
view - is a View that manages the control
parent - is container that keeps the control. The same View can be a view and a parent at the same time.
width and heigth - are minimal size of the control.
width and height - are minimal size of the control.
scale - the way of scaling the control when the parent is resized. Use DoNotScale constant if the
control should keep its original size.
*/

View File

@ -23,7 +23,7 @@ defined theme must have is a theme name.
Theme file is a simple text file that has similar to INI file format:
1. Every line started with '#' or '/' is a comment line.
2. Invalid lines - lines that do not contain symbol '=' - are skipped.
3. Valid lines are splitted in two parts:
3. Valid lines are split in two parts:
key - the text before the first '=' in the line
value - the text after the first '=' in the line (so, values can
include '=')
@ -32,7 +32,7 @@ Theme file is a simple text file that has similar to INI file format:
these symbols are removed, too. It is done to be able to start
or finish the object with a space rune
4. There is no mandatory keys - all of them are optional
5. Avaiable system keys that used to describe the theme:
5. Available system keys that used to describe the theme:
'title' - the theme title
'author' - theme author
'version' - theme version
@ -61,7 +61,7 @@ Theme file is a simple text file that has similar to INI file format:
Better way is:
Viewback=parent.ViewText
ViewText=parent.ViewBack
Converting text to real color fails and retuns black color if
Converting text to real color fails and returns black color if
a) the string does not look like real color(e.g, typo as in
'grean bold'), b) parent theme has not loaded yet, c) parent
theme does not have the color
@ -69,7 +69,7 @@ Theme file is a simple text file that has similar to INI file format:
Other keys are considered as objects - see Obj* constants, just drop
'Obj' at the beginning of the key name
One is not limited with only predefined color and object names.
The theme can inroduce its own objects, e.g. to provide a runes or
The theme can introduce its own objects, e.g. to provide a runes or
colors for new control that is not in standard library
To see the real world example of full featured theme, please see
included theme 'turbovision'
@ -121,7 +121,7 @@ func initThemeManager() {
ThemeReset()
}
// Reset removes all loaded themes from cache and reinitialize
// ThemeReset removes all loaded themes from cache and reinitialize
// the default theme
func ThemeReset() {
thememtx.Lock()

View File

@ -5,7 +5,7 @@ import (
term "github.com/nsf/termbox-go"
)
// Window is an implemetation of View managed by Composer.
// Window is an implementation of View managed by Composer.
type Window struct {
BaseControl
@ -140,6 +140,7 @@ func (wnd *Window) drawButtons() {
putCharUnsafe(pos, wnd.y, cCloseB)
}
// Draw repaints the control on the screen
func (wnd *Window) Draw() {
WindowManager().BeginUpdate()
defer WindowManager().EndUpdate()
@ -161,6 +162,9 @@ func (wnd *Window) Draw() {
wnd.drawButtons()
}
// HitTest returns type of a Window region at a given screen coordinates. The
// method is used to detect if a mouse cursor on a window border or outside,
// which window icon is under cursor etc
func (c *Window) HitTest(x, y int) HitResult {
if x > c.x && x < c.x+c.width-1 &&
y > c.y && y < c.y+c.height-1 {
@ -275,15 +279,14 @@ func (c *Window) ProcessEvent(ev Event) bool {
}
}
return true
} else {
if SendEventToChild(c, ev) {
return true
}
if c.onKeyDown != nil {
return c.onKeyDown.fn(ev, c.onKeyDown.data)
}
return false
}
if SendEventToChild(c, ev) {
return true
}
if c.onKeyDown != nil {
return c.onKeyDown.fn(ev, c.onKeyDown.data)
}
return false
default:
if ev.Type == EventMouse && ev.Key == term.MouseLeft {
DeactivateControls(c)
@ -360,16 +363,18 @@ func (w *Window) Visible() bool {
// SetVisible allows to temporarily remove the window from screen
// and show it later without reconstruction
func (w *Window) SetVisible(visible bool) {
if w.hidden == visible {
w.hidden = !visible
if w.hidden {
w.SetModal(false)
if WindowManager().topWindow() == w {
WindowManager().moveActiveWindowToBottom()
}
} else {
WindowManager().activateWindow(w)
if w.hidden != visible {
return
}
w.hidden = !visible
if w.hidden {
w.SetModal(false)
if WindowManager().topWindow() == w {
WindowManager().moveActiveWindowToBottom()
}
} else {
WindowManager().activateWindow(w)
}
}