Exemplo n.º 1
0
// Initialize the ncurses library. You must run this function prior to any
// other goncurses function in order for the library to work
func Init() (stdscr *Window, err error) {
	stdscr = &Window{C.initscr()}
	if unsafe.Pointer(stdscr.win) == nil {
		err = errors.New("An error occurred initializing ncurses")
	}
	return
}
Exemplo n.º 2
0
func initCurses() {
	C.initscr()
	C.cbreak()
	C.noecho()
	C.nonl()
	C.intrflush(C.stdscr, true)
	C.keypad(C.stdscr, false)
}
Exemplo n.º 3
0
func Initialize() (*Window, error) {
	window := (*Window)(C.initscr())

	if window == nil {
		return nil, CursesError{"Initialize failed"}
	}

	return window, nil
}
Exemplo n.º 4
0
func Initscr() (*Window, os.Error) {
	Stdwin = (*Window)(C.initscr())

	if Stdwin == nil {
		return nil, CursesError{"Initscr failed"}
	}

	return Stdwin, nil
}
Exemplo n.º 5
0
func Initscr() (*Window, error) {
	win := C.initscr()

	if win == nil {
		return nil, ErrorInit
	}

	return &Window{win}, nil
}
Exemplo n.º 6
0
func Hello(s string) {
	C.initscr()

	p := C.CString(fmt.Sprintf("Hello, %s", s))
	C.Printw(p)
	C.free(unsafe.Pointer(p))

	C.refresh()
	C.getch()
	C.endwin()
}
Exemplo n.º 7
0
func Newwin(rows int16, cols int16, starty int16, startx int16) (*Window, os.Error) {
	mt := C.CString("")
	C.setlocale(C.LC_ALL, mt)
	defer C.free(unsafe.Pointer(mt))
	Stdwin = (*Window)(C.initscr())

	if Stdwin == nil {
		return nil, CursesError{"Initscr failed"}
	}

	return Stdwin, nil
}
Exemplo n.º 8
0
func Initscr() (*Window, error) {
	mt := C.CString("")
	C.setlocale(C.LC_ALL, mt)
	defer C.free(unsafe.Pointer(mt))
	Stdwin = (*Window)(C.initscr())

	if Stdwin == nil {
		return nil, CursesError{"Initscr failed"}
	}

	return Stdwin, nil
}
Exemplo n.º 9
0
Arquivo: curses.go Projeto: 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
	}
}
Exemplo n.º 10
0
// Initializes curses.
// This function should be called before using the package.
func Initscr() *Window {
	Stdscr.cwin = C.initscr()
	return Stdscr
}
Exemplo n.º 11
0
/* Initializes NCurses library, returns the standard screen. */
func Init() *Window {
	return (*Window)(C.initscr())
}
Exemplo n.º 12
0
// Initializes curses.
// This function should be called before using the package.
func Initscr() *Window {
	Stdscr = (*Window)(C.initscr())
	return Stdscr
}
Exemplo n.º 13
0
// Initializes curses.
// This function should be called before using the package.
func Initscr() *Window {
	Stdscr = &Window{C.initscr()}
	return Stdscr
}