Skip to content

Commit 5b83cb9

Browse files
committed
Updated Package to new library format
* Eliminates the need for an external system module and instead relies on an internal modulemap
1 parent 913804b commit 5b83cb9

19 files changed

+36
-31
lines changed

Package.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:5.5
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -10,12 +10,10 @@ let package = Package(
1010
type: .dynamic,
1111
targets: ["Curses"]),
1212
],
13-
dependencies: [
14-
.package(url: "https://github.com/TheCoderMerlin/CNCURSES.git", from: "1.0.0"),
15-
],
1613
targets: [
1714
.target(
1815
name:"Curses",
19-
path:"Sources"),
16+
dependencies: ["ncurses"]),
17+
.systemLibrary(name: "ncurses")
2018
]
2119
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Sources/Curses.swift renamed to Sources/Curses/Curses.swift

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ You should have received a copy of the GNU General Public License
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
import CNCURSES
19+
import Foundation
20+
import ncurses
2021

2122

2223
// References:
@@ -65,8 +66,8 @@ internal class Curses {
6566
setlocale(LC_ALL, "")
6667

6768
// Initialize curses
68-
CNCURSES.initscr()
69-
CNCURSES.noecho()
69+
ncurses.initscr()
70+
ncurses.noecho()
7071

7172
startUpCount += 1
7273
}
@@ -75,7 +76,7 @@ internal class Curses {
7576
precondition(startUpCount == 1, "No instance of Curses is currently running.")
7677

7778
Curses.handler = nil
78-
CNCURSES.endwin()
79+
ncurses.endwin()
7980

8081
startUpCount -= 1
8182
}
@@ -95,40 +96,40 @@ internal class Curses {
9596
}
9697

9798
func setCursorStyle(_ cursorStyle:CursorStyle) {
98-
CNCURSES.curs_set(cursorStyle.rawValue)
99+
ncurses.curs_set(cursorStyle.rawValue)
99100
}
100101

101102
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
103104
}
104105

105106
func setKeyboardBufferingMode(_ keyboardBufferingMode:KeyboardBufferingMode) {
106107
switch (keyboardBufferingMode) {
107108
case .bufferingIsOn :
108-
CNCURSES.nocbreak()
109+
ncurses.nocbreak()
109110
case .bufferingIsOff:
110-
CNCURSES.cbreak()
111+
ncurses.cbreak()
111112
case .halfDelay(let tenthsOfSecond):
112-
CNCURSES.halfdelay(Int32(tenthsOfSecond))
113+
ncurses.halfdelay(Int32(tenthsOfSecond))
113114
}
114115
}
115116

116117
func setScroll(windowHandle:UnsafeMutablePointer<WINDOW>, enabled:Bool) {
117-
CNCURSES.scrollok(windowHandle, enabled)
118+
ncurses.scrollok(windowHandle, enabled)
118119
}
119120

120121
func getKey(windowHandle:UnsafeMutablePointer<WINDOW>) -> Key {
121-
let code = CNCURSES.wgetch(windowHandle)
122+
let code = ncurses.wgetch(windowHandle)
122123
let key = Key(code:code)
123124
return key
124125
}
125126

126127
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))
128129
}
129130

130131
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))
132133
}
133134

134135
func getWindowPosition(windowHandle:UnsafeMutablePointer<WINDOW>) -> Point {
@@ -138,50 +139,50 @@ internal class Curses {
138139
}
139140

140141
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))
142143
}
143144

144145
func refresh(windowHandle:UnsafeMutablePointer<WINDOW>) {
145-
CNCURSES.wrefresh(windowHandle)
146+
ncurses.wrefresh(windowHandle)
146147
}
147148

148149
func clear(windowHandle:UnsafeMutablePointer<WINDOW>) {
149-
CNCURSES.wclear(windowHandle)
150+
ncurses.wclear(windowHandle)
150151
}
151152

152153
func clearToEndOfLine(windowHandle:UnsafeMutablePointer<WINDOW>) {
153-
CNCURSES.wclrtoeol(windowHandle)
154+
ncurses.wclrtoeol(windowHandle)
154155
}
155156

156157
func clearToBottomOfWindow(windowHandle:UnsafeMutablePointer<WINDOW>) {
157-
CNCURSES.wclrtobot(windowHandle)
158+
ncurses.wclrtobot(windowHandle)
158159
}
159160

160161
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))
162163
}
163164

164165
func write(windowHandle:UnsafeMutablePointer<WINDOW>, string:String) {
165-
CNCURSES.waddstr(windowHandle, string)
166+
ncurses.waddstr(windowHandle, string)
166167
}
167168

168169
func attributeOn(windowHandle:UnsafeMutablePointer<WINDOW>, attributeValue:Int) {
169-
CNCURSES.wattron(windowHandle, Int32(attributeValue))
170+
ncurses.wattron(windowHandle, Int32(attributeValue))
170171
}
171172

172173
func attributeOff(windowHandle:UnsafeMutablePointer<WINDOW>, attributeValue:Int) {
173-
CNCURSES.wattroff(windowHandle, Int32(attributeValue))
174+
ncurses.wattroff(windowHandle, Int32(attributeValue))
174175
}
175176

176177
func attributeSet(windowHandle:UnsafeMutablePointer<WINDOW>, attributeValue:Int) {
177-
CNCURSES.wattrset(windowHandle, Int32(attributeValue))
178+
ncurses.wattrset(windowHandle, Int32(attributeValue))
178179
}
179180

180181
func backgroundSet(windowHandle:UnsafeMutablePointer<WINDOW>, attributeValue:Int, character:Character) {
181182
let unicodeScalars = character.unicodeScalars
182183
let ascii = UInt32(unicodeScalars[unicodeScalars.startIndex].value)
183184
let attributeAndCharacter : UInt32 = UInt32(attributeValue) | ascii
184-
CNCURSES.wbkgdset(windowHandle, attributeAndCharacter)
185+
ncurses.wbkgdset(windowHandle, attributeAndCharacter)
185186
}
186187

187188
var maxColorCount : Int {
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)