@@ -16,7 +16,8 @@ You should have received a copy of the GNU General Public License
16
16
along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
*/
18
18
19
- import CNCURSES
19
+ import Foundation
20
+ import ncurses
20
21
21
22
22
23
// References:
@@ -65,8 +66,8 @@ internal class Curses {
65
66
setlocale ( LC_ALL, " " )
66
67
67
68
// Initialize curses
68
- CNCURSES . initscr ( )
69
- CNCURSES . noecho ( )
69
+ ncurses . initscr ( )
70
+ ncurses . noecho ( )
70
71
71
72
startUpCount += 1
72
73
}
@@ -75,7 +76,7 @@ internal class Curses {
75
76
precondition ( startUpCount == 1 , " No instance of Curses is currently running. " )
76
77
77
78
Curses . handler = nil
78
- CNCURSES . endwin ( )
79
+ ncurses . endwin ( )
79
80
80
81
startUpCount -= 1
81
82
}
@@ -95,40 +96,40 @@ internal class Curses {
95
96
}
96
97
97
98
func setCursorStyle( _ cursorStyle: CursorStyle ) {
98
- CNCURSES . curs_set ( cursorStyle. rawValue)
99
+ ncurses . curs_set ( cursorStyle. rawValue)
99
100
}
100
101
101
102
func setKeyPadMode( windowHandle: UnsafeMutablePointer < WINDOW > ) {
102
- CNCURSES . keypad ( windowHandle, true ) // Processes special keys into special codes rather than escape sequences
103
+ ncurses . keypad ( windowHandle, true ) // Processes special keys into special codes rather than escape sequences
103
104
}
104
105
105
106
func setKeyboardBufferingMode( _ keyboardBufferingMode: KeyboardBufferingMode ) {
106
107
switch ( keyboardBufferingMode) {
107
108
case . bufferingIsOn :
108
- CNCURSES . nocbreak ( )
109
+ ncurses . nocbreak ( )
109
110
case . bufferingIsOff:
110
- CNCURSES . cbreak ( )
111
+ ncurses . cbreak ( )
111
112
case . halfDelay( let tenthsOfSecond) :
112
- CNCURSES . halfdelay ( Int32 ( tenthsOfSecond) )
113
+ ncurses . halfdelay ( Int32 ( tenthsOfSecond) )
113
114
}
114
115
}
115
116
116
117
func setScroll( windowHandle: UnsafeMutablePointer < WINDOW > , enabled: Bool ) {
117
- CNCURSES . scrollok ( windowHandle, enabled)
118
+ ncurses . scrollok ( windowHandle, enabled)
118
119
}
119
120
120
121
func getKey( windowHandle: UnsafeMutablePointer < WINDOW > ) -> Key {
121
- let code = CNCURSES . wgetch ( windowHandle)
122
+ let code = ncurses . wgetch ( windowHandle)
122
123
let key = Key ( code: code)
123
124
return key
124
125
}
125
126
126
127
func newWindow( position: Point , size: Size ) -> UnsafeMutablePointer < WINDOW > {
127
- return CNCURSES . newwin ( Int32 ( size. height) , Int32 ( size. width) , Int32 ( position. y) , Int32 ( position. x) )
128
+ return ncurses . newwin ( Int32 ( size. height) , Int32 ( size. width) , Int32 ( position. y) , Int32 ( position. x) )
128
129
}
129
130
130
131
func moveWindow( windowHandle: UnsafeMutablePointer < WINDOW > , to: Point ) {
131
- CNCURSES . mvwin ( windowHandle, Int32 ( to. y) , Int32 ( to. x) )
132
+ ncurses . mvwin ( windowHandle, Int32 ( to. y) , Int32 ( to. x) )
132
133
}
133
134
134
135
func getWindowPosition( windowHandle: UnsafeMutablePointer < WINDOW > ) -> Point {
@@ -138,50 +139,50 @@ internal class Curses {
138
139
}
139
140
140
141
func resizeWindow( windowHandle: UnsafeMutablePointer < WINDOW > , size: Size ) {
141
- CNCURSES . wresize ( windowHandle, Int32 ( size. height) , Int32 ( size. width) )
142
+ ncurses . wresize ( windowHandle, Int32 ( size. height) , Int32 ( size. width) )
142
143
}
143
144
144
145
func refresh( windowHandle: UnsafeMutablePointer < WINDOW > ) {
145
- CNCURSES . wrefresh ( windowHandle)
146
+ ncurses . wrefresh ( windowHandle)
146
147
}
147
148
148
149
func clear( windowHandle: UnsafeMutablePointer < WINDOW > ) {
149
- CNCURSES . wclear ( windowHandle)
150
+ ncurses . wclear ( windowHandle)
150
151
}
151
152
152
153
func clearToEndOfLine( windowHandle: UnsafeMutablePointer < WINDOW > ) {
153
- CNCURSES . wclrtoeol ( windowHandle)
154
+ ncurses . wclrtoeol ( windowHandle)
154
155
}
155
156
156
157
func clearToBottomOfWindow( windowHandle: UnsafeMutablePointer < WINDOW > ) {
157
- CNCURSES . wclrtobot ( windowHandle)
158
+ ncurses . wclrtobot ( windowHandle)
158
159
}
159
160
160
161
func move( windowHandle: UnsafeMutablePointer < WINDOW > , to: Point ) {
161
- CNCURSES . wmove ( windowHandle, Int32 ( to. y) , Int32 ( to. x) )
162
+ ncurses . wmove ( windowHandle, Int32 ( to. y) , Int32 ( to. x) )
162
163
}
163
164
164
165
func write( windowHandle: UnsafeMutablePointer < WINDOW > , string: String ) {
165
- CNCURSES . waddstr ( windowHandle, string)
166
+ ncurses . waddstr ( windowHandle, string)
166
167
}
167
168
168
169
func attributeOn( windowHandle: UnsafeMutablePointer < WINDOW > , attributeValue: Int ) {
169
- CNCURSES . wattron ( windowHandle, Int32 ( attributeValue) )
170
+ ncurses . wattron ( windowHandle, Int32 ( attributeValue) )
170
171
}
171
172
172
173
func attributeOff( windowHandle: UnsafeMutablePointer < WINDOW > , attributeValue: Int ) {
173
- CNCURSES . wattroff ( windowHandle, Int32 ( attributeValue) )
174
+ ncurses . wattroff ( windowHandle, Int32 ( attributeValue) )
174
175
}
175
176
176
177
func attributeSet( windowHandle: UnsafeMutablePointer < WINDOW > , attributeValue: Int ) {
177
- CNCURSES . wattrset ( windowHandle, Int32 ( attributeValue) )
178
+ ncurses . wattrset ( windowHandle, Int32 ( attributeValue) )
178
179
}
179
180
180
181
func backgroundSet( windowHandle: UnsafeMutablePointer < WINDOW > , attributeValue: Int , character: Character ) {
181
182
let unicodeScalars = character. unicodeScalars
182
183
let ascii = UInt32 ( unicodeScalars [ unicodeScalars. startIndex] . value)
183
184
let attributeAndCharacter : UInt32 = UInt32 ( attributeValue) | ascii
184
- CNCURSES . wbkgdset ( windowHandle, attributeAndCharacter)
185
+ ncurses . wbkgdset ( windowHandle, attributeAndCharacter)
185
186
}
186
187
187
188
var maxColorCount : Int {
0 commit comments