예제 #1
0
// Turn on/off buffering; raw user signals are passed to the program for
// handling. Overrides raw mode
func CBreak(on bool) {
	if on {
		C.cbreak()
		return
	}
	C.nocbreak()
}
예제 #2
0
파일: main.go 프로젝트: jameseb7/roguelike
func initCurses() {
	C.initscr()
	C.cbreak()
	C.noecho()
	C.nonl()
	C.intrflush(C.stdscr, true)
	C.keypad(C.stdscr, false)
}
예제 #3
0
func Cbreak() os.Error {
	in()
	defer out()
	if C.cbreak() == 0 {
		return CursesError{"Cbreak failed"}
	}
	return nil
}
예제 #4
0
파일: curses.go 프로젝트: blakejennings/fzf
func Init(theme *ColorTheme, black bool, mouse bool) {
	{
		in, err := os.OpenFile("/dev/tty", syscall.O_RDONLY, 0)
		if err != nil {
			panic("Failed to open /dev/tty")
		}
		_in = in
		// Break STDIN
		// syscall.Dup2(int(in.Fd()), int(os.Stdin.Fd()))
	}

	C.setlocale(C.LC_ALL, C.CString(""))
	_screen = C.newterm(nil, C.stderr, C.stdin)
	C.set_term(_screen)
	if mouse {
		C.mousemask(C.ALL_MOUSE_EVENTS, nil)
	}
	C.cbreak()
	C.noecho()
	C.raw() // stty dsusp undef

	intChan := make(chan os.Signal, 1)
	signal.Notify(intChan, os.Interrupt, os.Kill)
	go func() {
		<-intChan
		Close()
		os.Exit(1)
	}()

	if theme != nil {
		C.start_color()
		initPairs(theme, black)
		_color = attrColored
	} else {
		_color = attrMono
	}
}
예제 #5
0
파일: curses.go 프로젝트: zennro/fzf
func Init(color bool, color256 bool, black bool, mouse bool) {
	{
		in, err := os.OpenFile("/dev/tty", syscall.O_RDONLY, 0)
		if err != nil {
			panic("Failed to open /dev/tty")
		}
		_in = in
		// Break STDIN
		// syscall.Dup2(int(in.Fd()), int(os.Stdin.Fd()))
	}

	C.swapOutput()

	C.setlocale(C.LC_ALL, C.CString(""))
	C.initscr()
	if mouse {
		C.mousemask(C.ALL_MOUSE_EVENTS, nil)
	}
	C.cbreak()
	C.noecho()
	C.raw() // stty dsusp undef

	intChan := make(chan os.Signal, 1)
	signal.Notify(intChan, os.Interrupt, os.Kill)
	go func() {
		<-intChan
		Close()
		os.Exit(1)
	}()

	if color {
		C.start_color()
		var bg C.short
		if black {
			bg = C.COLOR_BLACK
		} else {
			C.use_default_colors()
			bg = -1
		}
		if color256 {
			DarkBG = 236
			C.init_pair(ColPrompt, 110, bg)
			C.init_pair(ColMatch, 108, bg)
			C.init_pair(ColCurrent, 254, DarkBG)
			C.init_pair(ColCurrentMatch, 151, DarkBG)
			C.init_pair(ColSpinner, 148, bg)
			C.init_pair(ColInfo, 144, bg)
			C.init_pair(ColCursor, 161, DarkBG)
			C.init_pair(ColSelected, 168, DarkBG)
		} else {
			DarkBG = C.COLOR_BLACK
			C.init_pair(ColPrompt, C.COLOR_BLUE, bg)
			C.init_pair(ColMatch, C.COLOR_GREEN, bg)
			C.init_pair(ColCurrent, C.COLOR_YELLOW, DarkBG)
			C.init_pair(ColCurrentMatch, C.COLOR_GREEN, DarkBG)
			C.init_pair(ColSpinner, C.COLOR_GREEN, bg)
			C.init_pair(ColInfo, C.COLOR_WHITE, bg)
			C.init_pair(ColCursor, C.COLOR_RED, DarkBG)
			C.init_pair(ColSelected, C.COLOR_MAGENTA, DarkBG)
		}
		_color = attrColored
	} else {
		_color = attrMono
	}
}
예제 #6
0
파일: curses.go 프로젝트: jncorpron/gocurse
func EnableCharBreak() error {
	if C.cbreak() == C.ERR {
		return CursesError{"Cbreak failed"}
	}
	return nil
}
예제 #7
0
파일: curses.go 프로젝트: AaronO/lightwave
func Cbreak() os.Error {
	if C.cbreak() == 0 {
		return CursesError{"Cbreak failed"}
	}
	return nil
}
예제 #8
0
파일: curses.go 프로젝트: zozor/gocurse
func Cbreak() error {
	if C.cbreak() == ERR {
		return ErrorCbreak
	}
	return nil
}
예제 #9
0
// No buffering.
func Cbreak() {
	C.cbreak()
}
예제 #10
0
파일: ncurses.go 프로젝트: Olreich/ncurses
/* Set the Input Mode to cbreak mode. This means that all characters typed are immediately avaialble to the application though Curses will pass control characters to the terminal before the application. This is the default mode of ncurses. */
func CBreak() {
	C.cbreak()
}
예제 #11
0
파일: curses.go 프로젝트: zyxar/gocurse
func Cbreak() error {
	if C.cbreak() == C.ERR {
		return CursesError{"cbreak failed"}
	}
	return nil
}