Skip to content
Myr

Merge pull request #252 from dominikh/portable-swapOutput

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Use ncurses's newterm instead of swapping stdout and stderr

authored by Junegunn Choi · committed by Junegunn Choi · parents 52771a6, 98f62b1 · Browse files · 1 file+4 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−9 removed

  • other:+4 added−9 removed

1 file+4 added−9 removed

modified:src/curses/curses.go+4 added-9 removed
2 unmodified lines
3/*4#include <ncurses.h>5#include <locale.h>6#cgo LDFLAGS: -lncurses7void swapOutput() {8 FILE* temp = stdout;9 stdout = stderr;10 stderr = temp;11}7*/8import "C"910import (
125 unmodified lines
136 _color func(int, bool) C.int137 _colorMap map[int]int138 _prevDownTime time.Time139 _clickY []int140 _screen *C.SCREEN141 Default16 *ColorTheme142 Dark256 *ColorTheme143 Light256 *ColorTheme144 FG int
104 unmodified lines
249 // Break STDIN250 // syscall.Dup2(int(in.Fd()), int(os.Stdin.Fd()))251 }252257 C.swapOutput()258253 C.setlocale(C.LC_ALL, C.CString(""))260 C.initscr()254 _screen = C.newterm(nil, C.stderr, C.stdin)255 C.set_term(_screen)256 if mouse {257 C.mousemask(C.ALL_MOUSE_EVENTS, nil)258 }259 C.cbreak()
50 unmodified lines
310}311312func Close() {313 C.endwin()319 C.swapOutput()314 C.delscreen(_screen)315}316317func GetBytes() []byte {318 c := getch(false)
223 unmodified lines