From 32f2f0dfa1cd9516b7ad421e7b46cec65e448bd6 Mon Sep 17 00:00:00 2001
From: Delyan Angelov <delian66@gmail.com>
Date: Mon, 24 Jan 2022 20:11:29 +0200
Subject: [PATCH] term.ui: fix shift notices, remove warning for main example

---
 vlib/term/ui/README.md | 19 ++++++++++---------
 vlib/term/ui/color.v   | 12 +++++++-----
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/vlib/term/ui/README.md b/vlib/term/ui/README.md
index 6bce054123..82e349665f 100644
--- a/vlib/term/ui/README.md
+++ b/vlib/term/ui/README.md
@@ -13,7 +13,6 @@ mut:
 }
 
 fn event(e &tui.Event, x voidptr) {
-	mut app := &App(x)
 	println(e)
 	if e.typ == .key_down && e.code == .escape {
 		exit(0)
@@ -33,14 +32,16 @@ fn frame(x voidptr) {
 	app.tui.flush()
 }
 
-mut app := &App{}
-app.tui = tui.init(
-	user_data: app
-	event_fn: event
-	frame_fn: frame
-	hide_cursor: true
-)
-app.tui.run() ?
+fn main() {
+	mut app := &App{}
+	app.tui = tui.init(
+		user_data: app
+		event_fn: event
+		frame_fn: frame
+		hide_cursor: true
+	)
+	app.tui.run() ?
+}
 ```
 
 See the `/examples/term.ui/` folder for more usage examples.
diff --git a/vlib/term/ui/color.v b/vlib/term/ui/color.v
index 0e31e77cfe..5ab51a6b0f 100644
--- a/vlib/term/ui/color.v
+++ b/vlib/term/ui/color.v
@@ -9,8 +9,8 @@ const value_range = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff]!
 pub const color_table = init_color_table()
 
 [direct_array_access]
-fn init_color_table() []int {
-	mut color_table_ := []int{len: 256}
+fn init_color_table() []u32 {
+	mut color_table_ := []u32{len: 256}
 	// ansi colors
 	color_table_[0] = 0x000000
 	color_table_[1] = 0x800000
@@ -33,12 +33,14 @@ fn init_color_table() []int {
 		r := ui.value_range[(i / 36) % 6]
 		g := ui.value_range[(i / 6) % 6]
 		b := ui.value_range[i % 6]
-		color_table_[i + 16] = ((r << 16) & 0xffffff) + ((g << 8) & 0xffff) + (b & 0xff)
+		color_table_[i + 16] = ((u32(r) << 16) & 0xffffff) + ((u32(g) << 8) & 0xffff) +
+			(u32(b) & 0xff)
 	}
 	// grayscale
 	for i in 0 .. 24 {
 		r := 8 + (i * 10)
-		color_table_[i + 232] = ((r << 16) & 0xffffff) + ((r << 8) & 0xffff) + (r & 0xff)
+		color_table_[i + 232] = ((u32(r) << 16) & 0xffffff) + ((u32(r) << 8) & 0xffff) +
+			(u32(r) & 0xff)
 	}
 	return color_table_
 }
@@ -66,7 +68,7 @@ fn approximate_rgb(r int, g int, b int) int {
 }
 
 fn lookup_rgb(r int, g int, b int) int {
-	color := (r << 16) + (g << 8) + b
+	color := (u32(r) << 16) + (u32(g) << 8) + u32(b)
 	// lookup extended colors only, coz non-extended can be changed by users.
 	for i in 16 .. 256 {
 		if ui.color_table[i] == color {