// Copyright 2026 The TCell Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // unicode just displays a Unicode test on your screen. // Press ESC to exit the program. package main import ( "fmt" "os" "github.com/gdamore/tcell/v3" "github.com/gdamore/tcell/v3/color" "github.com/gdamore/tcell/v3/encoding" ) var row = 0 var style = tcell.StyleDefault func putln(s tcell.Screen, str string) { s.PutStrStyled(1, row, str, style) row++ } func main() { s, e := tcell.NewScreen() if e != nil { fmt.Fprintf(os.Stderr, "%v\n", e) os.Exit(1) } encoding.Register() if e = s.Init(); e != nil { fmt.Fprintf(os.Stderr, "%v\n", e) os.Exit(1) } plain := tcell.StyleDefault bold := style.Bold(true) s.SetStyle(tcell.StyleDefault. Foreground(color.Black). Background(color.White)) s.Clear() // we can even try to use unicode window titles! s.SetTitle("Unicode Demonstration -- 🀯") quit := make(chan struct{}) style = bold putln(s, "Press Control-Q to Exit") putln(s, "Character set: "+s.CharacterSet()) style = plain putln(s, "English: October") putln(s, "Icelandic: oktΓ³ber") putln(s, "Arabic: Ψ£ΩƒΨͺوبر") putln(s, "Russian: октября") putln(s, "Greek: ΞŸΞΊΟ„Ο‰Ξ²ΟΞ―ΞΏΟ…") putln(s, "Chinese: 十月 (note, two double wide characters)") putln(s, "Combining: A\u030a (should look like Angstrom)") putln(s, "Emoticon: \U0001f618 (blowing a kiss)") putln(s, "Airplane: \u2708 (fly away)") putln(s, "Command: \u2318 (mac clover key)") putln(s, "Enclose: !\u20e3 (should be enclosed exclamation)") putln(s, "ZWJ: \U0001f9db\u200d\u2640 (female vampire)") putln(s, "ZWJ: \U0001f9db\u200d\u2642 (male vampire)") putln(s, "Family: \U0001f469\u200d\U0001f467\u200d\U0001f467 (woman girl girl)\n") putln(s, "Region: \U0001f1fa\U0001f1f8 (USA! USA!)\n") putln(s, "") putln(s, "Box:") putln(s, "β”Œβ”€β”¬β”€β”¬β”€β”€β”") putln(s, "β”‚Β·β”‚Β§β”‚ζœˆβ”‚ (bullet, lantern, CJK)") putln(s, "β”œβ”€β”Όβ”€β”Όβ”€β”€β”€") putln(s, "β”‚Aβ”‚1β”‚πŸ˜˜β”‚ (A, 1, Kiss)") putln(s, "β”œβ”€β”Όβ”€β”Όβ”€β”€β”€") putln(s, "β”‚Β·β”‚Ξ©β”‚πŸ‡¨πŸ‡­β”‚ (bullet, omega, Swiss)") putln(s, "β”œβ”€β”Όβ”€β”Όβ”€β”€β”€") putln(s, "│◆│↑│>=β”‚ (diamond, up arrow, greater-or-equal)") putln(s, "β””β”€β”΄β”€β”΄β”€β”€β”˜") s.Show() go func() { for { ev := <-s.EventQ() switch ev := ev.(type) { case *tcell.EventKey: switch ev.Key() { case tcell.KeyEscape, tcell.KeyEnter, tcell.KeyCtrlQ: close(quit) return case tcell.KeyCtrlL: s.Sync() } case *tcell.EventResize: s.Sync() } } }() <-quit s.Fini() }