当前位置: 首页>>代码示例>>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;未经允许,请勿转载。