GithubHelp home page GithubHelp logo

termbox-go's Introduction

Go Reference Build

IMPORTANT

This library is somewhat not maintained anymore. But I'm glad that it did what I wanted the most. It moved people away from "ncurses" mindset and these days we see both re-implementations of termbox API in various languages and even possibly better libs with similar API design. If you're looking for a Go lib that provides terminal-based user interface facilities, I've heard that gdamore/tcell is good (never used it myself). Also for more complicated interfaces and/or computer games I recommend you to consider using HTML-based UI. Having said that, termbox still somewhat works. In fact I'm writing this line of text right now in godit (which is a text editor written using termbox-go). So, be aware. Good luck and have a nice day.

Termbox

Termbox is a library that provides a minimalistic API which allows the programmer to write text-based user interfaces. The library is crossplatform and has both terminal-based implementations on *nix operating systems and a winapi console based implementation for windows operating systems. The basic idea is an abstraction of the greatest common subset of features available on all major terminals and other terminal-like APIs in a minimalistic fashion. Small API means it is easy to implement, test, maintain and learn it, that's what makes the termbox a distinct library in its area.

Installation

Install and update this go package with go get -u github.com/nsf/termbox-go

Examples

For examples of what can be done take a look at various examples in the _demos directory. You can try them with go run: go run _demos/keyboard.go

There are also some interesting projects using termbox-go:

  • godit is an emacsish lightweight text editor written using termbox.
  • gotetris is an implementation of Tetris.
  • sokoban-go is an implementation of sokoban game.
  • hecate is a hex editor designed by Satan.
  • httopd is top for httpd logs.
  • mop is stock market tracker for hackers.
  • termui is a terminal dashboard.
  • termloop is a terminal game engine.
  • xterm-color-chart is a XTerm 256 color chart.
  • gocui is a minimalist Go library aimed at creating console user interfaces.
  • dry is an interactive cli to manage Docker containers.
  • pxl displays images in the terminal.
  • snake-game is an implementation of the Snake game.
  • gone is a CLI pomodoro® timer.
  • Spoof.go controllable movement spoofing from the cli.
  • rat lets you compose shell commands to build terminal applications.
  • httplab An interactive web server.
  • wot Wait time during command is completed.
  • 2048-go is 2048 in Go.
  • jv helps you view JSON on the command-line.
  • pinger helps you to monitor numerous hosts using ICMP ECHO_REQUEST.
  • vixl44 lets you create pixel art inside your terminal using vim movements.
  • zterm is a typing game inspired by http://zty.pe/.
  • gotypist is a fun touch-typing tutor following Steve Yegge's method.
  • cointop is an interactive terminal based UI application for tracking cryptocurrencies.
  • pexpo is a terminal sending ping tool written in Go.
  • jid is an interactive JSON drill down tool using filtering queries like jq.
  • nonograminGo is a nonogram (aka. picross) in Go.
  • tower-of-go is a tiny maze game that runs on the terminal.

termbox-go's People

Contributors

andrew-d avatar beevik avatar cookieo9 avatar dajohi avatar dyegocosta avatar eiannone avatar ericfreese avatar evanmiller avatar felixonmars avatar gries avatar guillaumebreton avatar hirose31 avatar hugows avatar ichinaski avatar joelotter avatar jsoref avatar karalabe avatar kutuluk avatar marenu avatar mattn avatar meain avatar miguelmota avatar mum4k avatar nsf avatar rationull avatar sabey avatar scrouthtv avatar taylorchu avatar triangle345 avatar tsu-root avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

termbox-go's Issues

Wide unicode characters take two units

Hey, I was just trying out termbox (and it's great by the way!) and found out a problem for wide unicode characters. Actually it's a problem for wide runes displayed in fix-width font. My terminal (iTerm) prints wide characters twice as wide as ascii characters. As a result, if there's a wide rune, the drawn characters won't be aligned properly. Try this code:

package main

import (
    "github.com/nsf/termbox-go"
    "time"
)

func main() {
    err := termbox.Init()
    if err != nil {
        panic(err)
    }
    defer termbox.Close()

    cn := []rune{'你', '好', ',', '世', '界', '!'}
    en := []rune{'a', 'b', 'c', 'd', 'e', 'f'}
    for i := range cn {
        termbox.SetCell(i, 0, cn[i], termbox.ColorBlack, termbox.ColorWhite)
    }
    for i := range en {
        termbox.SetCell(i, 1, en[i], termbox.ColorRed, termbox.ColorWhite)
    }
    termbox.Flush()
    time.Sleep(5 * time.Second)
}

I'm not sure what should be changed to fix it yet. Should it

  • count wide runes as two characters in the buffer? (That would possibly produce overlapped characters)
  • Or if a wide rune is in buffer, then all non-wide runes are also drawn 2x wide?
  • Or provide an option on how runes are drawn?

Windows: simple program crashes

package main

import "github.com/nsf/termbox-go"

func main() {
    // Initialize termbox
    if err := termbox.Init(); err != nil {
        panic(err)
    }
    defer termbox.Close()

    // Clear screen, set a cell, flush buffer
    termbox.Clear(termbox.ColorDefault, termbox.ColorGreen)
    termbox.SetCell(1, 1, '#', termbox.ColorRed, termbox.ColorDefault)
    termbox.Flush()

    // Wait for events and respond appropriately
loop:
    for {
        switch ev := termbox.PollEvent(); ev.Type {
        case termbox.EventKey:
            switch ev.Key {
            case termbox.KeyEsc:
                break loop
            }
        }
    }
}

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x0 pc=0x76fe12da]

goroutine 1 [syscall]:
syscall.Syscall6(0x76ff4930, 0x5, 0x7, 0xf84008f000, 0x5dc0, ...)
C:/.../go/src/pkg/runtime/zsyscall_windows_amd64.c:97 +0x55
github.com/nsf/termbox-go.write_console_output_attribute(0x7, 0xf84008f000, 0x5dc000005dc0, 0x0, 0x0, ...)
C:/go/src/pkg/github.com/nsf/termbox-go/termbox_windows.go:99 +0xd6
github.com/nsf/termbox-go.Flush()
C:/go/src/pkg/github.com/nsf/termbox-go/api_windows.go:67 +0xc1
main.main()
C:/.../playground.go:15 +0xc1

goroutine 2 [syscall]:
created by runtime.main
C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist119677522/go/src/pkg/runtime/proc.c:221

goroutine 3 [syscall]:
syscall.Syscall6(0x76ff4fd0, 0x4, 0x3, 0xf840015a20, 0x1, ...)
C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist119677522/go/src/pkg/runtime/zsyscall_windows_amd64.c:97 +0x55
github.com/nsf/termbox-go.read_console_input(0x3, 0xf840015a20, 0x0, 0x0, 0x0, .
..)
C:/go/src/pkg/github.com/nsf/termbox-go/termbox_windows.go:138 +0x90
github.com/nsf/termbox-go.input_event_producer()
C:/go/src/pkg/github.com/nsf/termbox-go/termbox_windows.go:560 +0x5e
created by github.com/nsf/termbox-go.Init
C:/go/src/pkg/github.com/nsf/termbox-go/api_windows.go:51 +0x361

Init fails with io.EOF on darwin

I am a termui user and my termbox.Init is failing with the following error:

termbox: error while reading terminfo data: EOF

The EOF is coming from ti_read_string where you read rd, even though it successfully seeks to the offset.

func ti_read_string(rd *bytes.Reader, str_off, table int16) (string, error) {
var off int16
_, err := rd.Seek(int64(str_off), 0)
if err != nil {
    return "", err
}
err = binary.Read(rd, binary.LittleEndian, &off)
if err != nil {
    // err is io.EOF
    return "", err
}

SIGINT from Ctrl-C ignored

Suppose I was silly and ran the following program:

package main

import (
        "github.com/nsf/termbox-go"
)

func main() {
        termbox.Init()
        defer termbox.Close()

        for {
                e := termbox.PollEvent()
                termbox.SetCell(0, 0, e.Ch, termbox.ColorDefault, termbox.ColorDefault)
                termbox.Flush()
        }
}

While it does the intended thing of displaying the last key press, I accidentally wrote an infinite loop. Normally, I would just press ctrl-c to send a SIGINT, and the program would use the default signal handler and just quietly terminate. However, with termbox, instead the ctrl-c is not seen as a SIGINT. Instead, the ctrl-c will show up as an event from PollEvent. Obviously I'm being cheeky with this example, but in general, is there a way to tell termbox to respect the default signal handlers for things like SIGINT from ctrl-c or SIGTSTP from ctrl-z?

Shift+arrow keys

Is it possible to get shift+arrow key press events? I know that in Linux terminals, shift+arrow produces a different escape sequence (^[[1;2A instead of ^[[A), but since this is not included, I assume it is not so on Windows?

CellBuffer() not of much use, unreliable way to index?

I tried using CellBuffer() to read a cell's data but using Size() for the scalar did not work so well, you are using back_buffer.width.

back_buffer := T.CellBuffer()
w, h := T.Size()
index := x + (y * w)
if index < 0 || index > w*h {
    return ' ', ColorBlack, ColorBlack
}
cell := back_buffer[index]
return cell.Ch, termbox_to_color(cell.Fg), termbox_to_color(cell.Bg)

Key-up event

Perhaps I'm missing something, but I can't work out how to process a key being held down or released.

I had thought that a KeyEvent would be repeatedly fired if a key was held down, but this doesn't appear to be the case. Because of this, and the fact there's no key-up event, it makes it (seemingly) impossible to detect if a key is held down. I think either one of these (key up event or repeated firing of events) would be great to have.

Please do let me know if I'm being an idiot. Feel free to use the word 'idiot'. Thanks!

Termbox panics on Esc keypress when input mode is InputMouse

The following code initializes Termbox and loops infinitely - at least until you hit Esc, at which point it aborts with a panic: unreachable at line 372 in termbox.go:

package main
import "github.com/nsf/termbox-go"
import "os"

func main() {
    os.Setenv("TERM", "xterm")
    termbox.Init()
    defer termbox.Close()
    termbox.SetInputMode(termbox.InputMouse)
    for {
        termbox.PollEvent()
    }
}

This may be platform specific - I'm on OS X and haven't tested it on Windows or Linux yet. The os.Setenv call is a fix for issue #80. This only seems to happen when the input mode is InputMouse - the others work fine.

How to handle ctrl + Arrow keys input using termbox-go?

Can you please explain how one can handle "Ctrl + ArrowX" keys where X=Up, Down, Left, Right? Currently, my app using termbox-go just quits as soon as I hit Ctrl + any Arrow key, and so are most of the _demos/.go sample programs, except keyboard.go. Any documentation or explanation around it will be quite useful. Ideally, I would like to either handle it and take some action or at least make sure, my app doesn't just quit when user hits this key combination.

[Question] Why using tty instead of stdin/stdout, or just a Reader and Writer?

I am working on a small game, played via telnet connection.

I want to incorporate an editor in the game, and would like to just start the editor process with the net.Conn from the client as input/output.

I guess I could learn about how to create a new TTY, and somehow use that to start nsf/godit or build my own editor using termbox-go, but I am still uncertain about why termbox requires a TTY and not just readers/writers or stdin/stdout?

So, is there a short and sweet explanation about why a termbox library requires a TTY? :)

Mouse click events can't handle > 223 rows/columns

The mouse event can only have MouseX, and MouseY values that are in the range 0 to 222 (and -33 should a coordinate be greater than 222).

This happens because the event is sent to termbox is a sequence with a single 8-bit character for each of the X and Y locations and with 33 added to them. If a click occurs outside the range, then 0 is sent as the location, so termbox reports it as -33 (due to the adjustments it makes).

Looking at http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking , the likely cause of this is that termbox is using X10 compatibility mode, which behaves in this manner. According to this page there are several solutions, but they might be to difficult to work with in termbox, or might drop compatability, so the simplest solution might just be to document for the user this limitation, as 222 rows/columns might be big enough for most people.

I've only tested this on OS X, using xterm, but I suspect it affects linux, and bsd systems as well. I have no idea about the situation on Windows.

new terminfo parser

https://github.com/taylorchu/terminfo

I write a parser that parses entire terminfo file, so it gives more information in boolean and number part. This implementation also does not read in the whole file to slice to save memory.

I would like to remove custom hand-coded definition, and just use system-provided terminfo file. If system does not have terminfo file ready, termbox-go can copy existed terminfo to the project.

Cannot set InputMouse

I'm setting mouse input with:

termbox.SetInputMode(termbox.InputEsc | termbox.InputMouse)

and unfortunately, after building, I get the following error:

./menu.go:62: undefined: termbox.InputMouse

I am certain I have imported the module, and it has worked correctly until I added this line.

just alt or just ctrl key by themselves?

I have been experimenting a bit and I cant seem to figure out how to poll the event of just the ctrl key or just the alt key. Since these are not events that get polled; is there another way to determine if one of those two keys by themselves was pressed?

Thanks

OSX: /dev/tty hangs on close

It seems that on mac you can't block in read and call close at the same time. The close call gets blocked. Probably I shouldn't close /dev/tty stuff at all?

Non-blocking equivalent of PollEvent()?

Something like

func PeekEvent() Event, error
// Non-blocking

Use:

ev, err = PeekEvent()
if err == nil {
do_stuff_with_event(ev)
} else {
do other stuff()
}

might be nice for some applications. I might write one if I feel brave enough.

termbox-go doesn't play nice with syscall.Exec

Something termbox sets up with O_ASYNC/SIGIO leaves a bad state for an exec(3)'d process. If the following program is invoked without command-line arguments, it (correctly) loops indefinitely. If it is invoked with arguments, it will crash after a few iterations, printing "I/O possible".

package main

import (
    "os"
    "syscall"
    "github.com/nsf/termbox-go"
)

func main() {
    if len(os.Args) > 1 {
        termbox.Init()
        termbox.Close()
    }
    syscall.Exec(os.Args[0], os.Args, syscall.Environ())
}

The problem is fixed by not setting the O_ASYNC flag in Init() (which is obviously not a workable solution), but it is not fixed by unsetting the flag in Close() and/or by using signal.Stop() on the SIGIO channel.

An equivalent C program does not have this problem.

My environment is go version 1.4.2, Linux kernel version 4.0.1.

Реализация ColorDefault ломает бинарную совместимость с ANSI и xterm-256color

Функциональность ColorDefault хороша, но ее реализация ломает бинарную совместимость как с фундаментальными ANSI-цветами, так и с xterm-256color.

Может имеет смысл реализовывать эту функциональность отдельными методами, например

func SetCellDefaultFg(x, y int, ch rune, bg Attribute)
func SetCellDefaultBg(x, y int, ch rune, fg Attribute)
func SetCellDefault(x, y int, ch rune)

А признак дэфолтности хранить в отдельной сущности в Cell?

Например,
const AttrDefault Attribute = 1 << 16

тогда можно будет кастовать даже вот так:

SetCell(10, 10, 'A', 0|AttrDefault, 0|AttrDefault)

Я понимаю, что это, в свою очередь, ломет существующее апи, но мне почему-то кажется что несовместимость с годами устоявшимися бинарными значениями цветов намного хуже.

panic running termbox

I am accessing bash from custom client remotely over websocket, and termbox fails to run in this session.

# go run _demos/keyboard.go
panic: termbox: error while reading terminfo data: termbox: TERM environment variable not set

goroutine 1 [running]:
main.main()
        /root/go/src/github.com/nsf/termbox-go/_demos/keyboard.go:654 +0x74

goroutine 5 [runnable]:
os/signal.loop()
        /usr/lib/go/src/os/signal/signal_unix.go:20
created by os/signal.init.1
        /usr/lib/go/src/os/signal/signal_unix.go:28 +0x37
exit status 2

Here are more details - https://superuser.com/questions/997696/show-keys-pressed-in-custom-console

compatibility with Go 1.5rc1 on darwin/amd64

everything on go 1.4.2 is good. for 1.5rc1, the SetInputMode doesn't work.

in terminal.go:49, here is the function invocation:

termbox.SetInputMode(termbox.InputEsc | termbox.InputMouse)

--------------------------------------error messsage by go test------------------------------------
--- FAIL: TestTermboxImp (0.00s)
panic: runtime error: index out of range [recovered]
panic: runtime error: index out of range

goroutine 21 [running]:
testing.tRunner.func1(0xc8200be120)
/usr/local/go/src/testing/testing.go:450 +0x171
github.com/nsf/termbox-go.SetInputMode(0x5, 0x1)
/Users/ericwq/dev/go_works/src/github.com/nsf/termbox-go/api.go:384 +0x9d
ericwq/doctor/view.termboxImpl.SetInputMode(0x0, 0x0, 0x43cf78)
/Users/ericwq/dev/go_works/src/ericwq/doctor/view/terminal.go:49 +0x20
ericwq/doctor/view.(*termboxImpl).SetInputMode(0xc82009e580)
:5 +0xa1
ericwq/doctor/view.TestTermboxImp(0xc8200be120)
/Users/ericwq/dev/go_works/src/ericwq/doctor/view/terminal_test.go:28 +0x95
testing.tRunner(0xc8200be120, 0x55ce00)
/usr/local/go/src/testing/testing.go:456 +0x98
created by testing.RunTests
/usr/local/go/src/testing/testing.go:561 +0x86d

Fake input for termbox

is that possible to add the following func to api.go file.

this func can be used for automatic input and testing.

func FakeInput(s []byte) {
        if len(inbuf) > 0 && len(s) <= len(inbuf) {
                copy(inbuf, s)
        } else {
                inbuf = append(inbuf, s...)
        }
}

termbox demos don't run within ConsoleZ

I'm on Windows and am investigating termbox-go for a project. The demos run fine with a normal cmd.exe command prompt window, but don't work when the windows are within a tabbed console environment like ConsoleZ. Things work for a second, then appear to hang, and finally crash with the window tab going away and often a memory access error popup. I've never seen any go errors/panics.

This could be a ConsoleZ thing, but I've been running it for quite a while with other terminal applications and things have been OK.

termbox.PollEvent wait forever after reading from Stdin from tmux command

I don't know if this is a problem with termbox-go per se.

I have this simple program https://gist.github.com/vheon/74388c0dd68e21413eb8. If I ran this as

printf "foo\nbar\nqux" | ./simplebox

everything works fine, if I press <C-n> or <C-p> the selected line change.

if I have multiple sessions inside tmux and run

tmux list-sessions | ./simplebox

everything freeze and the only way to exit is to killall "simplebox" from another shell. I checked and the program is blocked on PollEvent.

catch alt key combination

Hi, it's rather a novice question.
How can I catch alt key combination? (ex : alt+s)
I tried this, but had no luck.

// in a key event loop
if (ev.Mod&term.ModAlt) != 0 {
    switch ev.Ch {
    case 'j': cursor.moveLeft()
    // and others..
    }
}

Thank you!

Deadlock on ConsoleZ

Seems like after rewriting windows implementation it just hangs with a deadlock. Needs to be fixed.

go get install line fails

Hey I was trying to install termbox-go using the go get command

kmiles@sita ~/src/go/gocurses/termbox-go $ sudo go get -u github.com/nsf/termbox-go
# github.com/nsf/termbox-go
/usr/lib/go/src/pkg/github.com/nsf/termbox-go/api.go:268: function ends without a return statement

If I add a "return event" line at the end of that function I can compile.. However, there's a very similar looking function immediately below with a line at the end saying panic("unreachable"), so I'm not sure the end of the PollRawEvent() function should even be reachable..

I'm not very well versed in go so I'm not really sure what's going on, but I thought I'd let you guys know.

Ctrl + Slash don't work as espected

when I press ctrl+"/" in godit, it doesn't work as undo, while ctrl+"-" does!
After tracing the code a bit, I found termbox-go don't recognise ctrl+"/"...

In api_common.go, I found that KeyCtrl7 KeyCtrlSlash KeyCtrlUnderscore are all bind to 0x1F, and the KeyCtrlSlash used in godit is actually generate by this.

And I continue tracing it ... Then in api.go, why pressing ctrl+"/" in termbox-go don't generate anything in input_comm channel?

How to handle terminal resizing?

I've never written text-based UIs before, but I thought I'd give termbox a try since it seems pretty simple. I'm starting to get the hang of it, but one thing that's confusing me is how to handle terminal window resize events. Does termbox support this case? Ideally, I'd like to be able to define a function that runs whenever the user resizes the terminal, and the function would take care of determining the new terminal size and re-drawing cells as necessary. I don't see any documentation about this, and I don't know how easy or hard it would be.

Hard-coded database path doesn't exist on OS X

I tried running godit on my mac, but termbox.Init failed with the following error:

termbox: error while reading terminfo data: open /usr/share/terminfo/x/xterm-256color: no such file or directory

Sounds like it's expecting Linux paths?

NetBSD support

NetBSD is not currently supported out of the box, but this is easy to fix:

$ cp syscalls_openbsd.go syscalls_netbsd.go

I also verified that the values in there matched the system headers. I would also guess that syscalls_freebsd.go would work as syscalls_dragonfly.go; I can look into this more if you'd like.

Control key modifier

When I was looking through the different keys you can listen on I noticed that control wasn't a modifier. This struck me as a bit odd, and even more so when not all normal keys could be found as a control variant. To be more specific there are, as far as I can see, no ctrl+arrow key combination.

What is the reason for this design? Could a control modifier be added without breaking old code? Either way could you add ctrl+arrow keys in the mean time?

Thanks for this awesome library, and for your time

Stopping termbox on Windows will swallow key events

I use termbox on Windows to have a small "program runner" utility. This utility will open different programs and redirect STDERR/STDIN/STDOUT while the program is running. While that is on, I intend to pause termbox using termbox.Close() and come back with Init() afterwards.

When closing termbox, it will still swallow some key events after it has been closed. This stops after a few (2-3) key events though.

Problem with Hash key

Hi,

I try to get the event key corresponding to '#' but i can't. In InputMode ESC, it returns me ESC. I'm on a AZERTY keyboard, and the combo for '#' if ALT Gr + "

Do you handle this ?

copy-paste a string of chinese characters not working

I'm trying to use the "_demos/editbox.go" example as input window, when I try to enter chinese characters it only takes the first one of the keyboard input method selection, the same happens if I try to paste it from other source.
So for example:
I copy: 英國人
but it only paste 英人
Is this easy to solve?

detect 256 color support

I'm thinking termbox is possible to read CCO to detect that terminal support 256 color.

termbox-go/terminfo.go

Lines 169 to 176 in cb87691

for i, _ := range funcs[:len(funcs)-2] {
funcs[i], err = ti_read_string(rd, str_offset+2*ti_funcs[i], table_offset)
if err != nil {
return
}
}
funcs[t_max_funcs-2] = "\x1b[?1000h"
funcs[t_max_funcs-1] = "\x1b[?1000l"

Uncontrolled buffer growth

After some hours of working the program is taking up a lot of RAM. It looks like charbuf in file termbox_windows.go growth uncontrolled.

func append_diff_line(y int) int {
    n := 0
    for x := 0; x < front_buffer.width; {
...
        charbuf = append(charbuf, char_info{attr: attr, char: char[0]})
...
        if !is_cjk && w == 2 {
            charbuf = append(charbuf, char_info{attr: attr, char: ' '})
        }
...

The problem is fixed by clear charbuf

func prepare_diff_messages() {
    // clear buffers
    diffbuf = diffbuf[:0]
    charbuf = charbuf[:0]

    var diff diff_msg
...

Uniform spacing

I'm trying to make a box and this is what I'm getting:

screen shot 2014-02-17 at 5 01 10 pm

If I set the line spacing on Terminal to 0.5 I get this:

screen shot 2014-02-17 at 5 04 51 pm

Even with this the characters overlap horizontally.

Is there any way to get uniform grid spacing without changing settings in Terminal?

termbox unit test

i try to write some test for my termbox based application. is that possible to abstract an interface for api.go? with that interface, it's easy to write mock implementation to test the result.

Additional mouse events?

I'm wondering if there's a way to read additional mouse events in Termbox, for example, mouse-up, or mouse drag. Some terminals seem to support them (I know one of xterm's modes supports mouse-drag, for example) but I'm not sure if there's a cross-platform way to do it.

Mouse click events not polled - windows

I'm running in powershell on windows 7 and I cannot get these mouse events to poll. I even tried running the keyboard example and mouse events are unresponsive. Is this a windows 7 limitation for termbox? I have not tried on linux yet.

Thanks

Scroll bar disappears in terminal as soon as termbox.Init() function is called.

On my linux terminal "xterm", as soon as I start any sample utility with termbox-go initialized, it looses its existing "scroll bar" but it comes back as soon as I exit the running utility. Is it expected? Why it is happening? Anyway to disable this behavior in termbox-go? fyi, I am using the master branch revision of termbox-go.

Refresh screen

How do I refresh the screen? Flush() does not seem to do it. I need something that works like Ctrl-L in vim or mc.

In my sorthead project, if I run du -a / |sorthead -nr, the first command in the pipe issues a lot of warnings to stderr. They go to termbox screen and break it. I know I could just run du 2>/dev/null, but refreshing the screen from my program would be better.

Blocking Input

Not much of an issue, but still. I love the library, but one problem I had was the blocking input. I was just wondering why you used this method, and if you are going to implement a non blocking method anytime as well?

I haven't done any real testing to see the consequences, but I added default to the select in PollEvent() that returns an event with event.Type set as a new event constant I set (after EventError i wrote in EventBlank). It seems to work fine for me, but I just wanted to know what the reason for using a blocking input vs a nonblocking input method?

Need / want Solaris / illumos support

On illumos/Solaris systems I cannot compile due to many undefined syscall_XXXX warnings. It looks like you generated the values automatically? Any chance I can help with that and get you a pull request?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.