From 12d73ee8db0f6748fabf65f4d0789c79f76c8d1f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 20 Apr 2015 17:35:32 -0700 Subject: 1114 - more primitives for managing the cursor --- cpp/070console | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'cpp/070console') diff --git a/cpp/070console b/cpp/070console index c8a51f9d..dcb6da96 100644 --- a/cpp/070console +++ b/cpp/070console @@ -3,6 +3,8 @@ :(before "End Includes") #include +//:: Display management + :(before "End Primitive Recipe Declarations") CURSOR_MODE, :(before "End Primitive Recipe Numbers") @@ -23,6 +25,68 @@ case RETRO_MODE: { break; } +:(before "End Primitive Recipe Declarations") +CLEAR_DISPLAY, +:(before "End Primitive Recipe Numbers") +Recipe_number["clear-display"] = CLEAR_DISPLAY; +:(before "End Primitive Recipe Implementations") +case CLEAR_DISPLAY: { + clear(); + break; +} + +:(before "End Primitive Recipe Declarations") +CLEAR_LINE_ON_DISPLAY, +:(before "End Primitive Recipe Numbers") +Recipe_number["clear-line-on-display"] = CLEAR_LINE_ON_DISPLAY; +:(before "End Primitive Recipe Implementations") +case CLEAR_LINE_ON_DISPLAY: { + clrtoeol(); + break; +} + +:(before "End Primitive Recipe Declarations") +PRINT_CHARACTER_TO_DISPLAY, +:(before "End Primitive Recipe Numbers") +Recipe_number["print-character-to-display"] = PRINT_CHARACTER_TO_DISPLAY; +:(before "End Primitive Recipe Implementations") +case PRINT_CHARACTER_TO_DISPLAY: { + vector arg = read_memory(instructions[pc].ingredients[0]); + addch(arg[0]); + break; +} + +:(before "End Primitive Recipe Declarations") +CURSOR_POSITION_ON_DISPLAY, +:(before "End Primitive Recipe Numbers") +Recipe_number["cursor-position-on-display"] = CURSOR_POSITION_ON_DISPLAY; +:(before "End Primitive Recipe Implementations") +case CURSOR_POSITION_ON_DISPLAY: { + size_t cursor_row = 0, cursor_column = 0; + getyx(stdscr, cursor_row, cursor_column); + vector row; + row.push_back(cursor_row); + write_memory(instructions[pc].products[0], row); + vector column; + column.push_back(cursor_column); + write_memory(instructions[pc].products[1], column); + break; +} + +:(before "End Primitive Recipe Declarations") +MOVE_CURSOR_ON_DISPLAY, +:(before "End Primitive Recipe Numbers") +Recipe_number["move-cursor-on-display"] = MOVE_CURSOR_ON_DISPLAY; +:(before "End Primitive Recipe Implementations") +case MOVE_CURSOR_ON_DISPLAY: { + vector row = read_memory(instructions[pc].ingredients[0]); + vector column = read_memory(instructions[pc].ingredients[1]); + move(row[0], column[0]); + break; +} + +//:: Keyboard management + :(before "End Primitive Recipe Declarations") WAIT_FOR_KEY_FROM_KEYBOARD, :(before "End Primitive Recipe Numbers") -- cgit 1.4.1-2-gfad0 u.html
blob: da75a2fa6ea4fd3ae2abb47256bee4acbe4e2fd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83