當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.chtype函數代碼示例

本文整理匯總了Golang中C.chtype函數的典型用法代碼示例。如果您正苦於以下問題:Golang chtype函數的具體用法?Golang chtype怎麽用?Golang chtype使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了chtype函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Addstr

// Since CGO currently can't handle varg C functions we'll mimic the
// ncurses addstr functions.
func (w *Window) Addstr(x, y int, str string, flags int32, v ...interface{}) {
	newstr := fmt.Sprintf(str, v...)

	w.MoveCursor(x, y)

	for i := 0; i < len(newstr); i++ {
		C.waddch(w.win, C.chtype(newstr[i])|C.chtype(flags))
	}
}
開發者ID:zozor,項目名稱:gocurse,代碼行數:11,代碼來源:curses.go

示例2: Addstr

// Since CGO currently can't handle varg C functions we'll mimic the
// ncurses addstr functions.
func (win *Window) Addstr(x, y int, str string, flags int32, v ...interface{}) {
	newstr := fmt.Sprintf(str, v...)

	win.Move(x, y)

	for i := 0; i < len(newstr); i++ {
		C.waddch((*C.WINDOW)(win), C.chtype(newstr[i])|C.chtype(flags))
	}
}
開發者ID:AaronO,項目名稱:lightwave,代碼行數:11,代碼來源:curses.go

示例3: Addstr

// Since CGO currently can't handle varg C functions we'll mimic the
// ncurses addstr functions.
// Per Issue 635 the variadic function definition needs to end with
// 'v ... interface {}' instead of 'v ...'.
func (win *Window) Addstr(x, y int, str string, flags int32, v ...interface{}) {
	in()
	defer out()
	newstr := fmt.Sprintf(str, v)

	win.move(x, y)

	for _, ch := range newstr {
		C.waddch((*C.WINDOW)(win), C.chtype(ch)|C.chtype(flags))
	}
}
開發者ID:serraavenger,項目名稱:gocurses,代碼行數:15,代碼來源:curses.go

示例4: AddString

// Since CGO currently can't handle varg C functions we'll mimic the
// ncurses addstr functions.
func (win *Window) AddString(x, y int, str string, flags int32, v ...interface{}) {
	var resolvedString string
	if v != nil {
		resolvedString = fmt.Sprintf(str, v)
	} else {
		resolvedString = str
	}

	win.Move(x, y)

	for i := 0; i < len(resolvedString); i++ {
		C.waddch((*C.WINDOW)(win), C.chtype(resolvedString[i])|C.chtype(flags))
	}
}
開發者ID:jncorpron,項目名稱:gocurse,代碼行數:16,代碼來源:curses.go

示例5: displayPickUpChoice

func displayPickUpChoice() []entity.ID {
	var str *C.char
	C.clear()
	C.move(0, 0)
	str = C.CString("Pick up what?\n")
	C.addstr(str)
	C.free(unsafe.Pointer(str))

	px, py := currentLevel.EntityLocation(player.EntityID())
	itemsAvailable := currentLevel.ItemsAt(px, py)
	for i, eid := range itemsAvailable {
		C.addch(C.chtype(inventoryChar(byte(i))))
		str = C.CString(" - ")
		C.addstr(str)
		C.free(unsafe.Pointer(str))
		str = C.CString(currentLevel.EntityByID(eid).EntityName())
		C.addstr(str)
		C.free(unsafe.Pointer(str))
	}

	itemsChosen := make([]bool, len(itemsAvailable))
	for {
		ch := C.getch()
		if ch == C.KEY_ENTER || ch == ' ' || ch == '\n' {
			break
		}
		if ch > C.int(255) {
			continue
		}
		if i := inventoryIndex(byte(ch)); (int(i) < len(itemsChosen)) &&
			(i != 255) {
			if itemsChosen[i] {
				itemsChosen[i] = false
				C.mvaddch(C.int(i+1), 2, C.chtype('-'))
			} else {
				itemsChosen[i] = true
				C.mvaddch(C.int(i+1), 2, C.chtype('+'))
			}
		}
	}

	result := make([]entity.ID, 0, len(itemsAvailable))
	for i, v := range itemsChosen {
		if v {
			result = append(result, itemsAvailable[i])
		}
	}
	return result
}
開發者ID:jameseb7,項目名稱:roguelike,代碼行數:49,代碼來源:draw.go

示例6: Border

func (w *Window) Border(ls, rs, ts, bs, tl, tr, bl, br int) error {
	if C.wborder(w.win, C.chtype(ls), C.chtype(rs),
		C.chtype(ts), C.chtype(bs), C.chtype(tl), C.chtype(tr),
		C.chtype(bl), C.chtype(br)) == ERR {

		return Error
	}
	return nil
}
開發者ID:zozor,項目名稱:gocurse,代碼行數:9,代碼來源:curses.go

示例7: Border

// Border uses the characters supplied to draw a border around the window.
// t, b, r, l, s correspond to top, bottom, right, left and side respectively.
func (w *Window) Border(ls, rs, ts, bs, tl, tr, bl, br Char) error {
	res := C.wborder(w.win, C.chtype(ls), C.chtype(rs), C.chtype(ts),
		C.chtype(bs), C.chtype(tl), C.chtype(tr), C.chtype(bl),
		C.chtype(br))
	if res == C.ERR {
		return errors.New("Failed to draw box around window")
	}
	return nil
}
開發者ID:trotha01,項目名稱:goncurses,代碼行數:11,代碼來源:window.go

示例8: displayInventory

func displayInventory() {
	var str *C.char
	C.clear()
	C.move(0, 0)
	str = C.CString("Inventory contents:\n")
	C.addstr(str)
	C.free(unsafe.Pointer(str))
	for i, v := range inventory {
		if inventory[i] != nil {
			C.addch(C.chtype(inventoryChar(byte(i))))
			str = C.CString(" - ")
			C.addstr(str)
			C.free(unsafe.Pointer(str))
			str = C.CString(v.name)
			C.addstr(str)
			C.free(unsafe.Pointer(str))
			C.addch(C.chtype('\n'))
		}
	}
}
開發者ID:jameseb7,項目名稱:roguelike,代碼行數:20,代碼來源:draw.go

示例9: Init

func Init(theme *ColorTheme, black bool, mouse bool) {
	C.setlocale(C.LC_ALL, C.CString(""))
	tty := C.c_tty()
	if tty == nil {
		fmt.Println("Failed to open /dev/tty")
		os.Exit(2)
	}
	_screen = C.c_newterm(tty)
	if _screen == nil {
		fmt.Println("Invalid $TERM: " + os.Getenv("TERM"))
		os.Exit(2)
	}
	C.set_term(_screen)
	if mouse {
		C.mousemask(C.ALL_MOUSE_EVENTS, nil)
		C.mouseinterval(0)
	}
	C.noecho()
	C.raw() // stty dsusp undef
	C.nonl()
	C.keypad(C.stdscr, true)

	delay := 50
	delayEnv := os.Getenv("ESCDELAY")
	if len(delayEnv) > 0 {
		num, err := strconv.Atoi(delayEnv)
		if err == nil && num >= 0 {
			delay = num
		}
	}
	C.set_escdelay(C.int(delay))

	_color = theme != nil
	if _color {
		C.start_color()
		InitTheme(theme, black)
		initPairs(theme)
		C.bkgd(C.chtype(C.COLOR_PAIR(C.int(ColNormal))))
		_colorFn = attrColored
	} else {
		_colorFn = attrMono
	}

	C.nodelay(C.stdscr, true)
	ch := C.getch()
	if ch != C.ERR {
		C.ungetch(ch)
	}
	C.nodelay(C.stdscr, false)
}
開發者ID:robertmeta,項目名稱:vimfiles,代碼行數:50,代碼來源:ncurses.go

示例10: Init

func (r *FullscreenRenderer) Init() {
	C.setlocale(C.LC_ALL, C.CString(""))
	tty := C.c_tty()
	if tty == nil {
		errorExit("Failed to open /dev/tty")
	}
	_screen = C.c_newterm(tty)
	if _screen == nil {
		errorExit("Invalid $TERM: " + os.Getenv("TERM"))
	}
	C.set_term(_screen)
	if r.mouse {
		C.mousemask(C.ALL_MOUSE_EVENTS, nil)
		C.mouseinterval(0)
	}
	C.noecho()
	C.raw() // stty dsusp undef
	C.nonl()
	C.keypad(C.stdscr, true)

	delay := 50
	delayEnv := os.Getenv("ESCDELAY")
	if len(delayEnv) > 0 {
		num, err := strconv.Atoi(delayEnv)
		if err == nil && num >= 0 {
			delay = num
		}
	}
	C.set_escdelay(C.int(delay))

	if r.theme != nil {
		C.start_color()
		initTheme(r.theme, r.defaultTheme(), r.forceBlack)
		initPairs(r.theme)
		C.bkgd(C.chtype(C.COLOR_PAIR(C.int(ColNormal.index()))))
		_colorFn = attrColored
	} else {
		initTheme(r.theme, nil, r.forceBlack)
		_colorFn = attrMono
	}

	C.nodelay(C.stdscr, true)
	ch := C.getch()
	if ch != C.ERR {
		C.ungetch(ch)
	}
	C.nodelay(C.stdscr, false)
}
開發者ID:junegunn,項目名稱:fzf,代碼行數:48,代碼來源:ncurses.go

示例11: NewWindow

func (r *FullscreenRenderer) NewWindow(top int, left int, width int, height int, border bool) Window {
	win := C.newwin(C.int(height), C.int(width), C.int(top), C.int(left))
	if r.theme != nil {
		C.wbkgd(win, C.chtype(C.COLOR_PAIR(C.int(ColNormal.index()))))
	}
	if border {
		pair, attr := _colorFn(ColBorder, 0)
		C.wcolor_set(win, pair, nil)
		C.wattron(win, attr)
		C.box(win, 0, 0)
		C.wattroff(win, attr)
		C.wcolor_set(win, 0, nil)
	}

	return &CursesWindow{
		impl:   win,
		top:    top,
		left:   left,
		width:  width,
		height: height,
	}
}
開發者ID:junegunn,項目名稱:fzf,代碼行數:22,代碼來源:ncurses.go

示例12: NewWindow

func NewWindow(top int, left int, width int, height int, border bool) *Window {
	win := C.newwin(C.int(height), C.int(width), C.int(top), C.int(left))
	if _color {
		C.wbkgd(win, C.chtype(C.COLOR_PAIR(C.int(ColNormal))))
	}
	if border {
		pair, attr := _colorFn(ColBorder, 0)
		C.wcolor_set(win, pair, nil)
		C.wattron(win, attr)
		C.box(win, 0, 0)
		C.wattroff(win, attr)
		C.wcolor_set(win, 0, nil)
	}

	return &Window{
		impl:   (*WindowImpl)(win),
		Top:    top,
		Left:   left,
		Width:  width,
		Height: height,
	}
}
開發者ID:robertmeta,項目名稱:vimfiles,代碼行數:22,代碼來源:ncurses.go

示例13: Background

func (win *Window) Background(colour int) {
	C.wbkgd((*C.WINDOW)(win), C.chtype(colour))
}
開發者ID:jncorpron,項目名稱:gocurse,代碼行數:3,代碼來源:curses.go

示例14: Addch

func (window *Window) Addch(ch int) {
	C.waddch(window.cwin, C.chtype(ch))
}
開發者ID:tncardoso,項目名稱:gocurses,代碼行數:3,代碼來源:curses.go

示例15: Box

func (win *Window) Box(verch, horch int) {
	C.box((*C.WINDOW)(win), C.chtype(verch), C.chtype(horch))
}
開發者ID:jncorpron,項目名稱:gocurse,代碼行數:3,代碼來源:curses.go


注:本文中的C.chtype函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。