Beispiel #1
0
/**
 *
 *	Get / Report cursors current postition.
 *
 * 	@FIXME: Refactor this garbage.
 *
 */
func CursorXY() (int, int) {
	var ch int
	var line string
	var ret []int

	fmt.Print(ESC + "6n")

	for ch != 'R' {
		ch = keyboard.RawKey()
		if ch != 27 && ch != '[' {
			ret = append(ret, ch)
		}
	}

	for _, value := range ret {
		line += string(int(value))
	}

	line = strings.TrimRight(line, "R")
	parts := strings.Split(line, ";")

	X, err := strconv.Atoi(parts[0])
	if err == nil {

	}

	Y, err := strconv.Atoi(parts[1])
	if err == nil {

	}

	return X, Y
}
Beispiel #2
0
func main() {
	var ch int

	fmt.Println("Press TAB to quit")
	for ch != 9 {
		// Good for special keys: Arrows, PgUp, PgDn, Home, End.
		ch = keyboard.RawKey()
		fmt.Printf("[%d][%c]\n", ch, ch)
	}
}