diff --git a/base_control.go b/base_control.go index 67bad88..ccaafb6 100644 --- a/base_control.go +++ b/base_control.go @@ -606,7 +606,7 @@ func (c *BaseControl) setClipper() { x, y, w, h := CalcClipper(c) c.clipper = &rect{x: x, y: y, w: w, h: h} } - +//HitTest -- func (c *BaseControl) HitTest(x, y int) мКнст.HitResult { if x > c.x && x < c.x+c.width-1 && y > c.y && y < c.y+c.height-1 { diff --git a/button.go b/button.go index 399e3bd..1d7d1a9 100644 --- a/button.go +++ b/button.go @@ -22,7 +22,7 @@ type Button struct { } /* -NewButton creates a new Button. +CreateButton creates a new 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 and heigth - are minimal size of the control. @@ -63,7 +63,7 @@ func CreateButton(parent Control, width, height int, title string, scale int) *B return b } -// Repaint draws the control on its View surface +//Draw Repaint draws the control on its View surface func (b *Button) Draw() { if b.hidden { return diff --git a/canvas.go b/canvas.go index 3a6f3f4..cc091b4 100644 --- a/canvas.go +++ b/canvas.go @@ -137,7 +137,7 @@ func Flush() { term.Flush() } -// SetSize sets the new Canvas size. If new size does not +// SetScreenSize sets the new Canvas size. If new size does not // equal old size then Canvas is recreated and cleared // with default colors. Both Canvas width and height must // be greater than 2 @@ -153,7 +153,7 @@ func SetScreenSize(width int, height int) { SetClipRect(0, 0, width, height) } -// Size returns current Canvas size +// ScreenSize returns current Canvas size func ScreenSize() (width int, height int) { return canvas.width, canvas.height } @@ -197,11 +197,11 @@ func SetTextColor(clr term.Attribute) { func SetBackColor(clr term.Attribute) { canvas.backColor = clr } - +//TextColor -- func TextColor() term.Attribute { return canvas.textColor } - +//BackColor -- func BackColor() term.Attribute { return canvas.backColor } @@ -280,7 +280,7 @@ func DrawText(x, y int, text string) { if unicode.Is(unicode.Scripts["Han"], elem.Ch) { x += 2 } else { - x += 1 + x++ } if firstdrawn && !drawn { @@ -338,7 +338,7 @@ func DrawTextVertical(x, y int, text string) { SetTextColor(elem.Fg) SetBackColor(elem.Bg) drawn := PutChar(x, y, elem.Ch) - y += 1 + y++ if firstdrawn && !drawn { break } diff --git a/checkbox.go b/checkbox.go index 5c5af40..d449ec5 100644 --- a/checkbox.go +++ b/checkbox.go @@ -52,7 +52,7 @@ func CreateCheckBox(parent Control, width int, title string, scale int) *CheckBo return c } -// Repaint draws the control on its View surface +//Draw Repaint draws the control on its View surface func (c *CheckBox) Draw() { if c.hidden { return diff --git a/clui2_api.go b/clui2_api.go index e16d532..d25ed9a 100644 --- a/clui2_api.go +++ b/clui2_api.go @@ -3,7 +3,7 @@ package clui import ( term "github.com/nsf/termbox-go" ) - +//InitLibrary -- func InitLibrary() bool { initThemeManager() initComposer() @@ -11,7 +11,7 @@ func InitLibrary() bool { return initCanvas() } -// Close closes console management and makes a console cursor visible +//DeinitLibrary Close closes console management and makes a console cursor visible func DeinitLibrary() { term.SetCursor(3, 3) term.Close() diff --git a/colorparse_test.go b/colorparse_test.go index 952559c..ed65875 100644 --- a/colorparse_test.go +++ b/colorparse_test.go @@ -2,10 +2,11 @@ package clui import ( "testing" + мКнст "./пакКонстанты" ) func TestParserEmpty(t *testing.T) { - prs := NewColorParser("", ColorBlack, ColorWhite) + prs := NewColorParser("", мКнст.ColorBlack, мКнст.ColorWhite) elem := prs.NextElement() @@ -17,20 +18,20 @@ func TestParserEmpty(t *testing.T) { func TestParserColors(t *testing.T) { prs := NewColorParser("acdefg\nf", - ColorBlack, ColorWhite) + мКнст.ColorBlack, мКнст.ColorWhite) elems := []TextElement{ - {ElemPrintable, 'a', ColorBlack, ColorWhite}, - {ElemBackColor, ' ', ColorBlack, ColorGreen}, - {ElemPrintable, 'c', ColorBlack, ColorGreen}, - {ElemTextColor, 'c', ColorRed, ColorGreen}, - {ElemPrintable, 'd', ColorRed, ColorGreen}, - {ElemBackColor, 'd', ColorRed, ColorWhite}, - {ElemPrintable, 'e', ColorRed, ColorWhite}, - {ElemTextColor, 'e', ColorBlack, ColorWhite}, - {ElemPrintable, 'f', ColorBlack, ColorWhite}, - {ElemPrintable, 'g', ColorBlack, ColorWhite}, - {ElemLineBreak, 'g', ColorBlack, ColorWhite}, - {ElemPrintable, 'f', ColorBlack, ColorWhite}, + {ElemPrintable, 'a', мКнст.ColorBlack, мКнст.ColorWhite}, + {ElemBackColor, ' ', мКнст.ColorBlack, мКнст.ColorGreen}, + {ElemPrintable, 'c', мКнст.ColorBlack, мКнст.ColorGreen}, + {ElemTextColor, 'c', мКнст.ColorRed, мКнст.ColorGreen}, + {ElemPrintable, 'd', мКнст.ColorRed, мКнст.ColorGreen}, + {ElemBackColor, 'd', мКнст.ColorRed, мКнст.ColorWhite}, + {ElemPrintable, 'e', мКнст.ColorRed, мКнст.ColorWhite}, + {ElemTextColor, 'e', мКнст.ColorBlack, мКнст.ColorWhite}, + {ElemPrintable, 'f', мКнст.ColorBlack, мКнст.ColorWhite}, + {ElemPrintable, 'g', мКнст.ColorBlack, мКнст.ColorWhite}, + {ElemLineBreak, 'g', мКнст.ColorBlack, мКнст.ColorWhite}, + {ElemPrintable, 'f', мКнст.ColorBlack, мКнст.ColorWhite}, } idx := 0 @@ -53,6 +54,6 @@ func TestParserColors(t *testing.T) { } el = prs.NextElement() - idx += 1 + idx++ } } diff --git a/composer.go b/composer.go index afd14d7..090319a 100644 --- a/composer.go +++ b/composer.go @@ -70,7 +70,7 @@ func termboxEventToLocal(ev term.Event) мКнст.Event { return e } -// Repaints everything on the screen +//RefreshScreen Repaints everything on the screen func RefreshScreen() { comp.BeginUpdate() term.Clear(мКнст.ColorWhite, мКнст.ColorBlack) @@ -118,7 +118,7 @@ func AddWindow(posX, posY, width, height int, title string) *Window { return window } -// Border returns the default window border +//BorderStyle returns the default window border func (c *Composer) BorderStyle() мКнст.BorderStyle { return c.windowBorder } @@ -697,7 +697,7 @@ func (c *Composer) processKey(ev мКнст.Event) { c.lastKey = term.KeyEsc } } - +//ProcessEvent -- func ProcessEvent(ev мКнст.Event) { switch ev.Type { case мКнст.EventCloseWindow: diff --git a/ctrlutil.go b/ctrlutil.go index 2d0f978..ce2f19a 100644 --- a/ctrlutil.go +++ b/ctrlutil.go @@ -1,8 +1,8 @@ package clui import ( - term "github.com/nsf/termbox-go" мКнст "./пакКонстанты" + term "github.com/nsf/termbox-go" ) // ThumbPosition returns a scrollbar thumb position depending @@ -263,9 +263,9 @@ func NextControl(parent Control, curr Control, next bool) Control { if next { return linear[nIndex] - } else { - return linear[pIndex] } + return linear[pIndex] + } // SendEventToChild tries to find a child control that should recieve the evetn diff --git a/edit_other.go b/edit_other.go index 507e51f..3051781 100644 --- a/edit_other.go +++ b/edit_other.go @@ -32,7 +32,7 @@ type EditField struct { onKeyPress func(term.Key, rune) bool } -// NewEditField creates a new EditField control +// CreateEditField creates a new EditField control // 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. diff --git a/label.go b/label.go index a0622c8..5736545 100644 --- a/label.go +++ b/label.go @@ -21,7 +21,7 @@ type Label struct { } /* -NewLabel creates a new label. +CreateLabel creates a new label. 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. diff --git a/listbox_test.go b/listbox_test.go index d7adf08..af5c432 100644 --- a/listbox_test.go +++ b/listbox_test.go @@ -2,11 +2,12 @@ package clui import ( "testing" + мКнст "./пакКонстанты" ) func TestListBox(t *testing.T) { width, height := 10, 5 - lbox := CreateListBox(nil, width, height, Fixed) + lbox := CreateListBox(nil, width, height, мКнст.Fixed) w, h := lbox.Size() if w != width { diff --git a/textutil_test.go b/textutil_test.go index 89f0cf7..043c083 100644 --- a/textutil_test.go +++ b/textutil_test.go @@ -2,6 +2,7 @@ package clui import ( "testing" + мКнст "./пакКонстанты" ) func TestEllipsize(t *testing.T) { @@ -46,16 +47,16 @@ func TestCutText(t *testing.T) { func TestAlignText(t *testing.T) { cases := []struct { in, want string - align Align + align мКнст.Align max, shift int }{ - {"abcdefgh", "abcde", AlignLeft, 5, 0}, - {"abcdefgh", "defgh", AlignRight, 5, 0}, - {"abcdefgh", "bcdef", AlignCenter, 5, 0}, - {"abcdefgh", "abcdefgh", AlignLeft, 10, 0}, - {"abcdefgh", "abcdefgh", AlignRight, 10, 2}, - {"abcdefgh", "abcdefgh", AlignCenter, 10, 1}, - {"abcdefg", "abcdefg", AlignCenter, 10, 2}, + {"abcdefgh", "abcde", мКнст.AlignLeft, 5, 0}, + {"abcdefgh", "defgh", мКнст.AlignRight, 5, 0}, + {"abcdefgh", "bcdef", мКнст.AlignCenter, 5, 0}, + {"abcdefgh", "abcdefgh", мКнст.AlignLeft, 10, 0}, + {"abcdefgh", "abcdefgh", мКнст.AlignRight, 10, 2}, + {"abcdefgh", "abcdefgh", мКнст.AlignCenter, 10, 1}, + {"abcdefg", "abcdefg", мКнст.AlignCenter, 10, 2}, } for _, c := range cases { @@ -69,25 +70,25 @@ func TestAlignText(t *testing.T) { func TestAlignColorizedText(t *testing.T) { cases := []struct { in, want string - align Align + align мКнст.Align max, shift int }{ // uncolored cases - {"abcdefgh", "abcde", AlignLeft, 5, 0}, - {"abcdefgh", "defgh", AlignRight, 5, 0}, - {"abcdefgh", "bcdef", AlignCenter, 5, 0}, - {"abcdefgh", "abcdefgh", AlignLeft, 10, 0}, - {"abcdefgh", "abcdefgh", AlignRight, 10, 2}, - {"abcdefgh", "abcdefgh", AlignCenter, 10, 1}, - {"abcdefg", "abcdefg", AlignCenter, 10, 2}, + {"abcdefgh", "abcde", мКнст.AlignLeft, 5, 0}, + {"abcdefgh", "defgh", мКнст.AlignRight, 5, 0}, + {"abcdefgh", "bcdef", мКнст.AlignCenter, 5, 0}, + {"abcdefgh", "abcdefgh", мКнст.AlignLeft, 10, 0}, + {"abcdefgh", "abcdefgh", мКнст.AlignRight, 10, 2}, + {"abcdefgh", "abcdefgh", мКнст.AlignCenter, 10, 1}, + {"abcdefg", "abcdefg", мКнст.AlignCenter, 10, 2}, // colored cases - {"abcdefg", "abcdefg", AlignCenter, 10, 2}, - {"abcdefgh", "abcdefgh", AlignRight, 10, 2}, - {"abcdefgh", "abcdefgh", AlignCenter, 10, 1}, - {"abcdefgh", "abcde", AlignLeft, 5, 0}, - {"abcdefgh", "defgh", AlignRight, 5, 0}, - {"abcdefgh", "bcdef", AlignCenter, 5, 0}, - {"abcdefg", "ab", AlignLeft, 2, 0}, + {"abcdefg", "abcdefg", мКнст.AlignCenter, 10, 2}, + {"abcdefgh", "abcdefgh", мКнст.AlignRight, 10, 2}, + {"abcdefgh", "abcdefgh", мКнст.AlignCenter, 10, 1}, + {"abcdefgh", "abcde", мКнст.AlignLeft, 5, 0}, + {"abcdefgh", "defgh", мКнст.AlignRight, 5, 0}, + {"abcdefgh", "bcdef", мКнст.AlignCenter, 5, 0}, + {"abcdefg", "ab", мКнст.AlignLeft, 2, 0}, } for _, c := range cases {