Procházet zdrojové kódy

Перегруппировка пакетов

SVI před 3 roky
rodič
revize
59a3f60e46
35 změnil soubory, kde provedl 373 přidání a 302 odebrání
  1. 0 91
      libtui/v0/app/app.go
  2. 3 3
      libtui/v0/examples/show_app/main.go
  3. 0 0
      libtui/v0/lib/color/color.go
  4. 0 0
      libtui/v0/lib/color/color_test.go
  5. 94 0
      libtui/v0/lib/cursor/cursor.go
  6. 68 0
      libtui/v0/lib/kernel/kernel.go
  7. 1 1
      libtui/v0/lib/kernel/kernel_test.go1
  8. 11 0
      libtui/v0/lib/line/line.go
  9. 1 1
      libtui/v0/lib/line_cell/cell/cell.go
  10. 0 0
      libtui/v0/lib/line_cell/cell/cell_test.go
  11. 7 6
      libtui/v0/lib/line_cell/line_cell.go
  12. 0 0
      libtui/v0/lib/pos/pos.go
  13. 0 0
      libtui/v0/lib/pos/pos_test.go
  14. 0 0
      libtui/v0/lib/pos/posx/posx.go
  15. 0 0
      libtui/v0/lib/pos/posx/posx_test.go
  16. 0 0
      libtui/v0/lib/pos/posy/posy.go
  17. 0 0
      libtui/v0/lib/pos/posy/posy_test.go
  18. 0 0
      libtui/v0/lib/safe_bool/safe_bool.go
  19. 0 0
      libtui/v0/lib/safe_bool/safe_bool_test.go
  20. 136 0
      libtui/v0/lib/screen/screen.go
  21. 1 1
      libtui/v0/lib/screen/screen_test.go
  22. 8 8
      libtui/v0/lib/screen/win_debug/win_debug.go
  23. 0 0
      libtui/v0/lib/size/size.go
  24. 0 0
      libtui/v0/lib/size/size_test.go
  25. 0 0
      libtui/v0/lib/size/sizex/sizex.go
  26. 0 0
      libtui/v0/lib/size/sizex/sizex_test.go
  27. 0 0
      libtui/v0/lib/size/sizey/sizey.go
  28. 0 0
      libtui/v0/lib/size/sizey/sizey_test.go
  29. 10 8
      libtui/v0/lib/widget/widget.go
  30. 0 42
      libtui/v0/screen/scr_cursor/scr_cursor.go
  31. 0 116
      libtui/v0/screen/screen.go
  32. 0 15
      libtui/v0/types/iapp.go
  33. 14 0
      libtui/v0/types/icursor.go
  34. 17 0
      libtui/v0/types/ikernel.go
  35. 2 10
      libtui/v0/types/iscreen.go

+ 0 - 91
libtui/v0/app/app.go

@@ -1,91 +0,0 @@
-// package app -- главный объект приложения
-package app
-
-import (
-	"fmt"
-
-	"github.com/gdamore/tcell"
-
-	"p78git.ddns.net/svi/libtui/alias"
-	"p78git.ddns.net/svi/libtui/screen"
-	"p78git.ddns.net/svi/libtui/types"
-)
-
-// App -- объектприложения
-type App struct {
-	screen *screen.Screen // Объект приложения
-	scr    tcell.Screen   // Библиотечный экран
-}
-
-// NewApp -- возвращает новый объект приложения
-func NewApp() (*App, error) {
-	sf := &App{}
-	var err error
-	sf.scr, err = tcell.NewScreen()
-	if err != nil {
-		return nil, fmt.Errorf("NewApp(): in create tcell.Screen, err=\n\t%w", err)
-	}
-	sf.screen, err = screen.NewScreen(sf)
-	if err != nil {
-		return nil, fmt.Errorf("NewApp(): i create IScreen, err=\n\t%w", err)
-	}
-	return sf, nil
-}
-
-// Screen -- возвращает объект экрана
-func (sf *App) Screen() types.IScreen {
-	return sf.screen
-}
-
-// Run -- запускает объект приложения в работу
-func (sf *App) Run() error {
-	defer func() {
-		sf.scr.Fini() // Завершить работу с экраном
-	}()
-	if err := sf.run_init(); err != nil {
-		return fmt.Errorf("App.Run(): ininit screen, err=\n\t%w", err)
-	}
-	sf.screen.Clear()
-	sf.screen.Draw() // sf.scr.Show()  // Обновить экран
-	sf.scr.EnableMouse()
-	for { // Главный цикл работы
-		ev := sf.scr.PollEvent() // Получить событие
-
-		// Process event
-		switch ev := ev.(type) {
-		case *tcell.EventResize:
-			sf.scr.Sync()
-			x, y := ev.Size()
-			sf.screen.Resize(alias.SizeX(x), alias.SizeY(y))
-		case *tcell.EventKey:
-			if ev.Key() == tcell.KeyCtrlQ { // ev.Key() == tcell.KeyEscape
-				return nil
-			}
-			if ev.Key() == tcell.KeyCtrlD { // Показать отладочную информацию
-				if sf.screen.WinDebug().IsVisible() { // Переключение состояния показа окна отладки
-					sf.screen.WinDebug().Hide()
-				} else {
-					sf.screen.WinDebug().Show()
-				}
-			}
-		case *tcell.EventMouse: // Мышка подвинулась
-			x, y := ev.Position()
-			sf.screen.SetMousePos(alias.PosX(x), alias.PosY(y))
-		}
-		sf.screen.Draw()
-	}
-}
-
-// Включение экрана терминала
-func (sf *App) run_init() error {
-	var err error
-	if err = sf.scr.Init(); err != nil {
-		return fmt.Errorf("App.run_init(): in init tcell.Screen, err=\n\t%w", err)
-	}
-	return nil
-}
-
-// Scr -- возвращает аппаратный экран
-func (sf *App) Scr() tcell.Screen {
-	return sf.scr
-}

+ 3 - 3
libtui/v0/examples/show_app/main.go

@@ -7,16 +7,16 @@ import (
 	"log"
 	"os"
 
-	"p78git.ddns.net/svi/libtui/app"
+	"p78git.ddns.net/svi/libtui/kernel"
 )
 
 func main() {
-	app, err := app.NewApp()
+	app, err := kernel.NewKernel()
 	if err != nil {
 		log.Printf("main(): in create IApp, err=\n\t%v\n", err)
 		os.Exit(1)
 	}
-	app.Screen().WinDebug().Show()
+	// app.Screen().WinDebug().Show()
 	if err = app.Run(); err != nil {
 		log.Printf("main(): in run IApp, err=\n\t%v\n", err)
 		os.Exit(2)

+ 0 - 0
libtui/v0/color/color.go → libtui/v0/lib/color/color.go


+ 0 - 0
libtui/v0/color/color_test.go → libtui/v0/lib/color/color_test.go


+ 94 - 0
libtui/v0/lib/cursor/cursor.go

@@ -0,0 +1,94 @@
+// package cursor -- глобальный курсор на экране
+package cursor
+
+import (
+	"fmt"
+
+	"github.com/gdamore/tcell"
+
+	"p78git.ddns.net/svi/libtui/alias"
+	"p78git.ddns.net/svi/libtui/line_cell/cell"
+	"p78git.ddns.net/svi/libtui/types"
+)
+
+// Cursor -- курсор на экране
+type Cursor struct {
+	*cell.Cell
+	app       types.IKernel
+	screen    types.IScreen
+	isVisible alias.IsVisible
+}
+
+// NewCursor -- возвращает новый объект экранного курсора
+func NewCursor(app types.IKernel) (*Cursor, error) {
+	if app == nil {
+		return nil, fmt.Errorf("NewScrCursor(): IScreen==nil")
+	}
+	sf := &Cursor{
+		app:       app,
+		screen:    app.Screen(),
+		Cell:      cell.NewCell(),
+		isVisible: true,
+	}
+	sf.SetLit(alias.Lit([]rune("↖")[0]))
+	return sf, nil
+}
+
+// Draw -- отрисовка курсора на экране
+func (sf *Cursor) Draw() {
+	sf.screen.SetCell(sf)
+	posX, posY := sf.Pos()
+	strOut := fmt.Sprintf("WinDebug.Draw(): pos=%v:%v", posX, posY)
+	colorFg := tcell.NewRGBColor(200, 200, 200)
+	style1 := tcell.StyleDefault
+	colorBg := tcell.NewRGBColor(0, 0, 255)
+	style1 = style1.Foreground(colorFg).Background(colorBg)
+	sf.drawText(alias.Style(style1), strOut)
+}
+
+func (sf *Cursor) drawText(style alias.Style, text string) {
+	posX0, posY0 := sf.Pos()
+	posX, posY := posX0, posY0
+	// Сначала вычислить квадрант экрана
+	sizeX, sizeY := sf.screen.Size()
+	if alias.SizeX(posX) >= sizeX/2 { // Кусор в правой половине
+		posX -= 30
+	} else {
+		posX += 5
+	}
+	if alias.SizeY(posY) >= sizeY/2 { // Курсор в нижней половине
+		posY -= 5
+	} else {
+		posY += 5
+	}
+	for adr, r := range text {
+		cell := cell.NewCell()
+		cell.SetPos(posX+alias.PosX(adr), posY)
+		cell.SetLit(alias.Lit(r))
+		cell.SetStyle(style)
+		sf.screen.SetCell(cell)
+	}
+}
+
+// SetPos -- устанавливает позицию курсора с подстройкой фона
+func (sf *Cursor) SetPos(posX alias.PosX, posY alias.PosY) {
+	cell := sf.screen.GetCell(posX, posY)
+	color := cell.BgColor()
+	sf.BgColorSet(color)
+	sf.Cell.SetPos(posX, posY)
+}
+
+// Hide -- скрывает курсор от отображения
+func (sf *Cursor) Hide() {
+	sf.isVisible = false
+}
+
+// Show -- показывает курсор для отображения
+func (sf *Cursor) Show() {
+	sf.isVisible = true
+}
+
+// IsVisible -- возвращает признак отображения курсора
+func (sf *Cursor) IsVisible() alias.IsVisible {
+	return sf.isVisible
+}

+ 68 - 0
libtui/v0/lib/kernel/kernel.go

@@ -0,0 +1,68 @@
+// package app -- главный объект приложения
+package kernel
+
+import (
+	"context"
+	"fmt"
+
+	"p78git.ddns.net/svi/libtui/cursor"
+	"p78git.ddns.net/svi/libtui/screen"
+	"p78git.ddns.net/svi/libtui/types"
+)
+
+// Kernel -- объектприложения
+type Kernel struct {
+	screen   types.IScreen   // Объект приложения
+	cursor   types.ICursor   // Глобальный курсор
+	ctxBg    context.Context // Неотменяемый контекст ядра
+	ctx      context.Context // Контекст ядра
+	fnCancel func()
+}
+
+// NewKernel -- возвращает новый объект приложения
+func NewKernel() (*Kernel, error) {
+	ctxBg := context.Background()
+	ctx, fnCancel := context.WithCancel(ctxBg)
+	sf := &Kernel{
+		ctxBg:    ctxBg,
+		ctx:      ctx,
+		fnCancel: fnCancel,
+	}
+	var err error
+	sf.screen, err = screen.NewScreen(sf)
+	if err != nil {
+		return nil, fmt.Errorf("NewKernel(): i create IScreen, err=\n\t%w", err)
+	}
+	sf.cursor, err = cursor.NewCursor(sf)
+	if err != nil {
+		return nil, fmt.Errorf("NewKernel(): in create ICursor, err=\n\t%w", err)
+	}
+	return sf, nil
+}
+
+// Screen -- возвращает объект экрана
+func (sf *Kernel) Screen() types.IScreen {
+	return sf.screen
+}
+
+// Cursor -- возвращает курсор экрана
+func (sf *Kernel) Cursor() types.ICursor {
+	return sf.cursor
+}
+
+// Run -- запускает объект приложения в работу
+func (sf *Kernel) Run() error {
+	<-sf.ctx.Done()
+	go sf.screen.Run()
+	return nil
+}
+
+// CancelApp -- отменяет глобальный онтекст приложения
+func (sf *Kernel) CancelApp() {
+	sf.fnCancel()
+}
+
+// Ctx -- возвращает глобальный контекст ядра
+func (sf *Kernel) Ctx() context.Context {
+	return sf.ctx
+}

+ 1 - 1
libtui/v0/app/app_test.go1 → libtui/v0/lib/kernel/kernel_test.go1

@@ -1,4 +1,4 @@
-package app
+package kernel
 
 import (
 	"testing"

+ 11 - 0
libtui/v0/lib/line/line.go

@@ -0,0 +1,11 @@
+// package line -- графический примитив линия
+package line
+
+import "p78git.ddns.net/svi/libtui/types"
+
+// Line -- графический примитив линия
+type Line struct {
+	posBeg types.IPos   // Начало линии
+	posEnd types.IPos   // Конец линии
+	color  types.IColor // Цвет линии
+}

+ 1 - 1
libtui/v0/line_cell/cell/cell.go → libtui/v0/lib/line_cell/cell/cell.go

@@ -3,7 +3,7 @@ package cell
 
 import (
 	"github.com/gdamore/tcell"
-	
+
 	"p78git.ddns.net/svi/libtui/alias"
 	"p78git.ddns.net/svi/libtui/pos"
 	"p78git.ddns.net/svi/libtui/types"

+ 0 - 0
libtui/v0/line_cell/cell/cell_test.go → libtui/v0/lib/line_cell/cell/cell_test.go


+ 7 - 6
libtui/v0/line_cell/line_cell.go → libtui/v0/lib/line_cell/line_cell.go

@@ -13,13 +13,13 @@ import (
 
 // LineCell -- строка ячеек
 type LineCell struct {
-	app types.IApp
+	app types.IKernel
 	scr types.IScreen
 	lst []types.ICell
 }
 
 // NewLineCell -- возвращает новую строку ячеек
-func NewLineCell(app types.IApp) (*LineCell, error) {
+func NewLineCell(app types.IKernel) (*LineCell, error) {
 	if app == nil {
 		return nil, fmt.Errorf("NewLineCell(): IApp==nil")
 	}
@@ -40,12 +40,13 @@ func (sf *LineCell) Draw() {
 	cell.SetLit(alias.Lit([]rune("=")[0]))
 	st0 := tcell.StyleDefault
 	st0 = st0.Background(tcell.ColorBlue).Foreground(tcell.ColorYellow)
-	x0, y0 := sf.app.Screen().Cursor().Pos()
-	scr := sf.app.Scr()
+	cell.SetStyle(alias.Style(st0))
+	x0, y0 := sf.app.Cursor().Pos()
+	scr := sf.app.Screen()
 	for x := x0; x < x0+20; x++ {
 		for y := y0; y < y0+5; y++ {
-			// cell.SetPos(x, y)
-			scr.SetCell(int(x), int(y), st0, []rune("`")[0])
+			cell.SetPos(x, y)
+			scr.SetCell(cell)
 		}
 	}
 	// }

+ 0 - 0
libtui/v0/pos/pos.go → libtui/v0/lib/pos/pos.go


+ 0 - 0
libtui/v0/pos/pos_test.go → libtui/v0/lib/pos/pos_test.go


+ 0 - 0
libtui/v0/pos/posx/posx.go → libtui/v0/lib/pos/posx/posx.go


+ 0 - 0
libtui/v0/pos/posx/posx_test.go → libtui/v0/lib/pos/posx/posx_test.go


+ 0 - 0
libtui/v0/pos/posy/posy.go → libtui/v0/lib/pos/posy/posy.go


+ 0 - 0
libtui/v0/pos/posy/posy_test.go → libtui/v0/lib/pos/posy/posy_test.go


+ 0 - 0
libtui/v0/safe_bool/safe_bool.go → libtui/v0/lib/safe_bool/safe_bool.go


+ 0 - 0
libtui/v0/safe_bool/safe_bool_test.go → libtui/v0/lib/safe_bool/safe_bool_test.go


+ 136 - 0
libtui/v0/lib/screen/screen.go

@@ -0,0 +1,136 @@
+// package screen -- объект экрана
+package screen
+
+import (
+	"fmt"
+
+	"github.com/gdamore/tcell"
+
+	"p78git.ddns.net/svi/libtui/alias"
+	"p78git.ddns.net/svi/libtui/line_cell/cell"
+	"p78git.ddns.net/svi/libtui/pos"
+
+	// "p78git.ddns.net/svi/libtui/screen/win_debug"
+	"p78git.ddns.net/svi/libtui/size"
+	"p78git.ddns.net/svi/libtui/types"
+)
+
+// Screen -- объект экрана
+type Screen struct {
+	app      types.IKernel
+	scr      tcell.Screen // Библиотечный экран
+	size     types.ISize  // Размер экрана
+	posShift types.IPos   // Смещение начала координат
+}
+
+// NewScreen -- возвращаетновый экран
+func NewScreen(app types.IKernel) (*Screen, error) {
+	if app == nil {
+		return nil, fmt.Errorf("NewScreen(): IApp==nil")
+	}
+	scr, err := tcell.NewScreen()
+	if err != nil {
+		return nil, fmt.Errorf("NewScreen(): in create tcell.Screen, err=\n\t%w", err)
+	}
+	sf := &Screen{
+		app:      app,
+		scr:      scr,
+		size:     size.NewSize(),
+		posShift: pos.NewPos(),
+	}
+	return sf, nil
+}
+
+// Run -- запускает экран в работу
+func (sf *Screen) Run() error {
+	defer func() {
+		sf.scr.Fini()
+		sf.app.CancelApp()
+	}()
+	if err := sf.scr.Init(); err != nil {
+		return fmt.Errorf("Screen.Run(): in init tcell.Screen, err=\n\t%w", err)
+	}
+	sf.scr.EnableMouse()
+	sf.scr.HideCursor()
+	sf.setGeomShift()
+	sf.Clear()
+	sf.Draw() // sf.scr.Show()  // Обновить экран
+	for {     // Главный цикл работы
+		event := sf.scr.PollEvent() // Получить событие
+		// Process event
+		switch ev := event.(type) {
+		case *tcell.EventResize:
+			sf.scr.Sync()
+			x, y := ev.Size()
+			sf.size.Set(alias.SizeX(x), alias.SizeY(y))
+		case *tcell.EventKey:
+			if ev.Key() == tcell.KeyCtrlQ { // ev.Key() == tcell.KeyEscape
+				return nil
+			}
+			if ev.Key() == tcell.KeyCtrlD { // Показать отладочную информацию
+				// if sf.screen.WinDebug().IsVisible() { // Переключение состояния показа окна отладки
+				// 	sf.screen.WinDebug().Hide()
+				// } else {
+				// 	sf.screen.WinDebug().Show()
+				// }
+			}
+		case *tcell.EventMouse: // Мышка подвинулась
+			x, y := ev.Position()
+			sf.app.Cursor().SetPos(alias.PosX(x), alias.PosY(y))
+		}
+		sf.Draw()
+	}
+}
+
+// setGeomShift -- устанавливает геометрическое начало координат
+func (sf *Screen) setGeomShift() {
+	_, sizeY := sf.scr.Size()
+	// Сдвигает по вертикали координату вниз
+	sf.posShift.Set(0, alias.PosY(sizeY))
+}
+
+// Size -- возвращает размер экрана
+func (sf *Screen) Size() (alias.SizeX, alias.SizeY) {
+	return sf.size.Get()
+}
+
+// WinDebug -- возвращает объект окна отладки экрана
+// func (sf *Screen) WinDebug() types.IWinDebug {
+// 	return sf.winDebug
+// }
+
+// Resize -- изменяет размер экрана
+func (sf *Screen) Resize(x alias.SizeX, y alias.SizeY) {
+	sf.size.Set(x, y)
+}
+
+// GetCell -- возвращает ячейку по указанному знакоместу
+func (sf *Screen) GetCell(posX alias.PosX, posY alias.PosY) types.ICell {
+	rune_, _, style, _ := sf.scr.GetContent(int(posX), int(posY))
+	cell := cell.NewCell()
+	cell.SetLit(alias.Lit(rune_))
+	cell.SetStyle(alias.Style(style))
+	return cell
+}
+
+// SetCell -- устанавливает ячейку на экран
+func (sf *Screen) SetCell(cell types.ICell) {
+	x, y := cell.Pos()
+	style := cell.Style()
+	lit := cell.Lit()
+	sf.scr.SetCell(int(x), int(y), tcell.Style(style), rune(lit))
+}
+
+// Draw -- отрисовка экранасебя по требованию
+func (sf *Screen) Draw() {
+	sf.scr.Clear()
+	// sf.winDebug.Draw()
+	// sf.cursor.Draw()
+	sf.scr.Show() // Обновить экран
+
+}
+
+// Clear -- очистка экрана
+func (sf *Screen) Clear() {
+	sf.scr.Clear() // Зачистить экран перед началом работы
+}

+ 1 - 1
libtui/v0/screen/screen_test.go → libtui/v0/lib/screen/screen_test.go

@@ -9,7 +9,7 @@ import (
 // Тестер для экрана
 type tester struct {
 	t    *testing.T
-	app  types.IApp
+	app  types.IKernel
 	scr  *Screen
 	iscr types.IScreen
 	err  error

+ 8 - 8
libtui/v0/screen/win_debug/win_debug.go → libtui/v0/lib/screen/win_debug/win_debug.go

@@ -15,23 +15,23 @@ import (
 // WinDebug -- окно отладки для экрана
 type WinDebug struct {
 	*widget.Widget
-	app    types.IApp
+	app    types.IKernel
 	screen types.IScreen
 }
 
 // NewWinDebug -- возвращает новое окно отладки для экрана
-func NewWinDebug(screen types.IScreen) (*WinDebug, error) {
-	if screen == nil {
-		return nil, fmt.Errorf("NewWinDebug(): IScreen==nil")
+func NewWinDebug(app types.IKernel) (*WinDebug, error) {
+	if app == nil {
+		return nil, fmt.Errorf("NewWinDebug(): IApp==nil")
 	}
-	widget, err := widget.NewWidget(screen)
+	widget, err := widget.NewWidget(app)
 	if err != nil {
 		return nil, fmt.Errorf("NewWinDebug(): in create IWidget, err=\n\t%w", err)
 	}
 	sf := &WinDebug{
 		Widget: widget,
-		app:    screen.App(),
-		screen: screen,
+		app:    app,
+		screen: app.Screen(),
 	}
 	return sf, nil
 }
@@ -70,7 +70,7 @@ func (sf *WinDebug) Draw() {
 	}
 	sf.Widget.Draw()
 
-	posX, posY := sf.screen.Cursor().Pos()
+	posX, posY := sf.app.Cursor().Pos()
 	strOut := fmt.Sprintf("WinDebug.Draw(): pos=%v:%v", posX, posY)
 	colorFg := tcell.NewRGBColor(200, 200, 200)
 	style1 := tcell.StyleDefault

+ 0 - 0
libtui/v0/size/size.go → libtui/v0/lib/size/size.go


+ 0 - 0
libtui/v0/size/size_test.go → libtui/v0/lib/size/size_test.go


+ 0 - 0
libtui/v0/size/sizex/sizex.go → libtui/v0/lib/size/sizex/sizex.go


+ 0 - 0
libtui/v0/size/sizex/sizex_test.go → libtui/v0/lib/size/sizex/sizex_test.go


+ 0 - 0
libtui/v0/size/sizey/sizey.go → libtui/v0/lib/size/sizey/sizey.go


+ 0 - 0
libtui/v0/size/sizey/sizey_test.go → libtui/v0/lib/size/sizey/sizey_test.go


+ 10 - 8
libtui/v0/widget/widget.go → libtui/v0/lib/widget/widget.go

@@ -18,7 +18,7 @@ import (
 
 // Widget -- базовый виджет для построения других виджетов
 type Widget struct {
-	app       types.IApp
+	app       types.IKernel
 	screen    types.IScreen
 	pos       types.IPos
 	size      types.ISize
@@ -32,13 +32,13 @@ type Widget struct {
 }
 
 // NewWidget -- возвращает новый виджет
-func NewWidget(screen types.IScreen) (*Widget, error) {
-	if screen == nil {
-		return nil, fmt.Errorf("NewWidget(): IScreen==nil")
+func NewWidget(app types.IKernel) (*Widget, error) {
+	if app == nil {
+		return nil, fmt.Errorf("NewWidget(): IApp==nil")
 	}
 	sf := &Widget{
-		app:       screen.App(),
-		screen:    screen,
+		app:       app,
+		screen:    app.Screen(),
 		pos:       pos.NewPos(),
 		size:      size.NewSize(),
 		bufLine:   make([]*line_cell.LineCell, 0),
@@ -105,8 +105,9 @@ func (sf *Widget) Resize(sizeX alias.SizeX, sizeY alias.SizeY) {
 	fnAddLine := func(_y_ alias.PosY) {
 		line, err := line_cell.NewLineCell(sf.app)
 		if err != nil {
-			sf.app.Scr().Fini()
 			fmt.Printf("Widget.Resize().fnAddLine(): in crete line_cell, err=\n\t%v\n", err)
+			sf.app.CancelApp()
+			return
 		}
 		for dx := posX; dx < posX+alias.PosX(sizeX); dx++ {
 			cell_ := cell.NewCell()
@@ -116,8 +117,9 @@ func (sf *Widget) Resize(sizeX alias.SizeX, sizeY alias.SizeY) {
 			cell_.SetLit(sf.lit)
 			cell_.SetPos(dx, _y_)
 			if err = line.AddCell(cell_); err != nil {
-				sf.app.Scr().Fini()
 				fmt.Printf("Widget.Resize().fnAddLine(): in crete cell, err=\n\t%v\n", err)
+				sf.app.CancelApp()
+				return
 			}
 		}
 		sf.bufLine = append(sf.bufLine, line)

+ 0 - 42
libtui/v0/screen/scr_cursor/scr_cursor.go

@@ -1,42 +0,0 @@
-// package scr_cursor -- курсор на экране
-package scr_cursor
-
-import (
-	"fmt"
-
-	"p78git.ddns.net/svi/libtui/alias"
-	"p78git.ddns.net/svi/libtui/line_cell/cell"
-	"p78git.ddns.net/svi/libtui/types"
-)
-
-// ScrCursor -- курсор на экране
-type ScrCursor struct {
-	*cell.Cell
-	scr types.IScreen
-}
-
-// NewScrCursor -- возвращает новый объект экранного курсора
-func NewScrCursor(scr types.IScreen) (*ScrCursor, error) {
-	if scr == nil {
-		return nil, fmt.Errorf("NewScrCursor(): IScreen==nil")
-	}
-	sf := &ScrCursor{
-		scr:  scr,
-		Cell: cell.NewCell(),
-	}
-	sf.SetLit(alias.Lit([]rune("↖")[0]))
-	return sf, nil
-}
-
-// Draw -- отрисовка курсора на экране
-func (sf *ScrCursor) Draw() {
-	sf.scr.SetCell(sf)
-}
-
-// SetPos -- устанавливает позицию курсора с подстройкой фона
-func (sf *ScrCursor) SetPos(posX alias.PosX, posY alias.PosY) {
-	cell := sf.scr.GetCell(posX, posY)
-	color := cell.BgColor()
-	sf.BgColorSet(color)
-	sf.Cell.SetPos(posX, posY)
-}

+ 0 - 116
libtui/v0/screen/screen.go

@@ -1,116 +0,0 @@
-// package screen -- объект экрана
-package screen
-
-import (
-	"fmt"
-
-	"github.com/gdamore/tcell"
-
-	"p78git.ddns.net/svi/libtui/alias"
-	"p78git.ddns.net/svi/libtui/line_cell/cell"
-	"p78git.ddns.net/svi/libtui/screen/scr_cursor"
-	"p78git.ddns.net/svi/libtui/screen/win_debug"
-	"p78git.ddns.net/svi/libtui/size"
-	"p78git.ddns.net/svi/libtui/types"
-)
-
-// Screen -- объект экрана
-type Screen struct {
-	app      types.IApp
-	scr      tcell.Screen
-	size     types.ISize         // Размер экрана
-	winDebug *win_debug.WinDebug // Окно отладки
-	cursor   *scr_cursor.ScrCursor
-}
-
-// NewScreen -- возвращаетновый экран
-func NewScreen(app types.IApp) (*Screen, error) {
-	if app == nil {
-		return nil, fmt.Errorf("NewScreen(): IApp==nil")
-	}
-	sf := &Screen{
-		app:  app,
-		scr:  app.Scr(),
-		size: size.NewSize(),
-	}
-	var err error
-	sf.winDebug, err = win_debug.NewWinDebug(sf)
-	if err != nil {
-		return nil, fmt.Errorf("NewScreen(): in creatre IWinDebug, err=\n\t%w", err)
-	}
-	sf.cursor, err = scr_cursor.NewScrCursor(sf)
-	if err != nil {
-		return nil, fmt.Errorf("NewScreen(): in create ScrCursor, err=\n\t%w", err)
-	}
-	sf.scr.HideCursor()
-	return sf, nil
-}
-
-// Size -- возвращает размер экрана
-func (sf *Screen) Size() (alias.SizeX, alias.SizeY) {
-	return sf.size.Get()
-}
-
-// WinDebug -- возвращает объект окна отладки экрана
-func (sf *Screen) WinDebug() types.IWinDebug {
-	return sf.winDebug
-}
-
-// Resize -- изменяет размер экрана
-func (sf *Screen) Resize(x alias.SizeX, y alias.SizeY) {
-	sf.size.Set(x, y)
-}
-
-// SetMousePos -- устанавливает позицию мыши
-func (sf *Screen) SetMousePos(x alias.PosX, y alias.PosY) {
-	sf.cursor.SetPos(x, y)
-	if sf.winDebug.IsVisible() { // Установить позицию окна отладки, если оно видно
-		sf.winDebug.SetPos(x, y)
-	}
-}
-
-// App -- возвращает объект приложения
-func (sf *Screen) App() types.IApp {
-	return sf.app
-}
-
-// MousePos -- возвращает позицию мыши
-func (sf *Screen) MousePos() (alias.PosX, alias.PosY) {
-	return sf.cursor.Pos()
-}
-
-// GetCell -- возвращает ячейку по указанному знакоместу
-func (sf *Screen) GetCell(posX alias.PosX, posY alias.PosY) types.ICell {
-	rune_, _, style, _ := sf.scr.GetContent(int(posX), int(posY))
-	cell := cell.NewCell()
-	cell.SetLit(alias.Lit(rune_))
-	cell.SetStyle(alias.Style(style))
-	return cell
-}
-
-// SetCell -- устанавливает ячейку на экран
-func (sf *Screen) SetCell(cell types.ICell) {
-	x, y := cell.Pos()
-	style := cell.Style()
-	lit := cell.Lit()
-	sf.scr.SetCell(int(x), int(y), tcell.Style(style), rune(lit))
-}
-
-// Draw -- отрисовка экранасебя по требованию
-func (sf *Screen) Draw() {
-	sf.scr.Clear()
-	sf.winDebug.Draw()
-	sf.cursor.Draw()
-	sf.scr.Show() // Обновить экран
-
-}
-
-// Clear -- очистка экрана
-func (sf *Screen) Clear() {
-	sf.scr.Clear() // Зачистить экран перед началом работы
-}
-
-// Cursor -- возвращает курсор экрана
-func (sf *Screen) Cursor() types.ICell {
-	return sf.cursor
-}

+ 0 - 15
libtui/v0/types/iapp.go

@@ -1,15 +0,0 @@
-package types
-
-import (
-	"github.com/gdamore/tcell"
-)
-
-// IApp -- объект приложения
-type IApp interface {
-	// Screen -- объект экрана
-	Screen() IScreen
-	// Run -- запускает объект приложения в работу
-	Run() error
-	// Scr -- возвращает аппаратный экран
-	Scr() tcell.Screen
-}

+ 14 - 0
libtui/v0/types/icursor.go

@@ -0,0 +1,14 @@
+package types
+
+import "p78git.ddns.net/svi/libtui/alias"
+
+// ICursor -- объект курсора
+type ICursor interface {
+	ICell
+	// Show -- показывает курсор
+	Show()
+	// Hide -- скрывает курсор
+	Hide()
+	// IsVisible -- признак видимости курсора
+	IsVisible() alias.IsVisible
+}

+ 17 - 0
libtui/v0/types/ikernel.go

@@ -0,0 +1,17 @@
+package types
+
+import "context"
+
+// IKernel -- объект ядра
+type IKernel interface {
+	// Screen -- объект экрана
+	Screen() IScreen
+	// Run -- запускает объект ядра в работу
+	Run() error
+	// Cursor -- возвращает глобальный курсор ядра
+	Cursor() ICursor
+	// Ctx -- контекст ядра
+	Ctx() context.Context
+	// CancelApp -- отмена контекста ядра
+	CancelApp()
+}

+ 2 - 10
libtui/v0/types/iscreen.go

@@ -10,14 +10,6 @@ type IScreen interface {
 	Size() (alias.SizeX, alias.SizeY)
 	// Resize -- изменить размеры экрана
 	Resize(alias.SizeX, alias.SizeY)
-	// WinDebug -- возвращает объект окна отладки экрана
-	WinDebug() IWinDebug
-	// SetMousePos -- устанавливает позицию мыши экрана
-	SetMousePos(alias.PosX, alias.PosY)
-	// MousePos -- возвращаетпозицию мыши
-	MousePos() (alias.PosX, alias.PosY)
-	// App -- возвращает объект приложения
-	App() IApp
 	// SetCell -- отрисовывает знакоместо на экране
 	SetCell(ICell)
 	// Draw -- отрисовывает себя по  требованию
@@ -26,6 +18,6 @@ type IScreen interface {
 	Clear()
 	// GetCell -- возвращает ячейку по указанным координатам
 	GetCell(alias.PosX, alias.PosY) ICell
-	// Cursor -- возвращает курсор экрана
-	Cursor() ICell
+	// Run -- запускает экран в работу
+	Run() error
 }