notcurses 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd810d72f17887b44315230c0eaa70cd0a1989fb036cad822fb40f9cebbca536
4
+ data.tar.gz: 9e837bda0413fac9c29a9807c75ab034b30f9ed2d31ad95d5283f1994a9c2348
5
+ SHA512:
6
+ metadata.gz: c959c58c769bca7a7a03d0649ed12ae889e1e6135e0f6cdd0d232d660e2f70f78bc9edd519952ad5722f9a504b88c57d1950a8868218d04776c7122789913b05
7
+ data.tar.gz: 607a60f4a6cff5faec9c1e22e34d37ae8180ad7e67f8c6d2577e0637d5ef2468969eb7ec03ab735bc1b6cc7e1fea1f8995756f29e46f29a36cf1e91dcfcf0184
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.2.0@notcurses
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ gem 'bundler', '~> 2.0'
9
+ gem 'debug', '>= 1.9.2'
10
+ gem "minitest", "~> 5.0"
11
+ gem 'pry', '>= 0.14.2'
12
+ gem 'pry-doc', '>= 1.4.0'
13
+ gem 'pry-nav', '>= 1.0.0'
14
+ gem 'pry-remote', '>= 0.1.8'
15
+ gem 'pry-rescue', '>= 1.5.2'
16
+ gem 'pry-theme', '>= 1.3.1'
17
+ gem 'rake', '>= 1.64.1'
18
+ gem 'rubocop', '~> 1.64.0'
19
+ end
20
+
data/Gemfile.lock ADDED
@@ -0,0 +1,93 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ notcurses (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ coderay (1.1.3)
11
+ debug (1.9.2)
12
+ irb (~> 1.10)
13
+ reline (>= 0.3.8)
14
+ interception (0.5)
15
+ io-console (0.7.2)
16
+ irb (1.14.0)
17
+ rdoc (>= 4.0.0)
18
+ reline (>= 0.4.2)
19
+ json (2.7.2)
20
+ language_server-protocol (3.17.0.3)
21
+ method_source (1.1.0)
22
+ minitest (5.24.1)
23
+ parallel (1.25.1)
24
+ parser (3.3.4.0)
25
+ ast (~> 2.4.1)
26
+ racc
27
+ pry (0.14.2)
28
+ coderay (~> 1.1)
29
+ method_source (~> 1.0)
30
+ pry-doc (1.5.0)
31
+ pry (~> 0.11)
32
+ yard (~> 0.9.11)
33
+ pry-nav (1.0.0)
34
+ pry (>= 0.9.10, < 0.15)
35
+ pry-remote (0.1.8)
36
+ pry (~> 0.9)
37
+ slop (~> 3.0)
38
+ pry-rescue (1.6.0)
39
+ interception (>= 0.5)
40
+ pry (>= 0.12.0)
41
+ pry-theme (1.3.1)
42
+ coderay (~> 1.1)
43
+ psych (5.1.2)
44
+ stringio
45
+ racc (1.8.0)
46
+ rainbow (3.1.1)
47
+ rake (13.2.1)
48
+ rdoc (6.7.0)
49
+ psych (>= 4.0.0)
50
+ regexp_parser (2.9.2)
51
+ reline (0.5.9)
52
+ io-console (~> 0.5)
53
+ rexml (3.3.2)
54
+ strscan
55
+ rubocop (1.64.1)
56
+ json (~> 2.3)
57
+ language_server-protocol (>= 3.17.0)
58
+ parallel (~> 1.10)
59
+ parser (>= 3.3.0.2)
60
+ rainbow (>= 2.2.2, < 4.0)
61
+ regexp_parser (>= 1.8, < 3.0)
62
+ rexml (>= 3.2.5, < 4.0)
63
+ rubocop-ast (>= 1.31.1, < 2.0)
64
+ ruby-progressbar (~> 1.7)
65
+ unicode-display_width (>= 2.4.0, < 3.0)
66
+ rubocop-ast (1.31.3)
67
+ parser (>= 3.3.1.0)
68
+ ruby-progressbar (1.13.0)
69
+ slop (3.6.0)
70
+ stringio (3.1.1)
71
+ strscan (3.1.0)
72
+ unicode-display_width (2.5.0)
73
+ yard (0.9.36)
74
+
75
+ PLATFORMS
76
+ x86_64-linux
77
+
78
+ DEPENDENCIES
79
+ bundler (~> 2.0)
80
+ debug (>= 1.9.2)
81
+ minitest (~> 5.0)
82
+ notcurses!
83
+ pry (>= 0.14.2)
84
+ pry-doc (>= 1.4.0)
85
+ pry-nav (>= 1.0.0)
86
+ pry-remote (>= 0.1.8)
87
+ pry-rescue (>= 1.5.2)
88
+ pry-theme (>= 1.3.1)
89
+ rake (>= 1.64.1)
90
+ rubocop (~> 1.64.0)
91
+
92
+ BUNDLED WITH
93
+ 2.4.1
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Notcurses-ruby
2
+
3
+ # WARNING
4
+
5
+ BEFORE YOU GO ANY FURTHER, this is a WIP!!! This is not to be used for
6
+ ANYTHING IMPORTANT WHATSOEVER!!! This is my first time using SWIG and my first
7
+ time developing a Ruby extension. It's got very basic functionality working,
8
+ but only works on Linux right now. YOU HAVE BEEN WARNED!!!
9
+
10
+ # Overview
11
+
12
+ This is a SWIG-generated Ruby extension for Notcurses, a truly 31337 library
13
+ for developing TUIs. Notcurses is a modern reimagining of the classic Curses
14
+ library known to many. It supports true color, has built-in widgets and many
15
+ other nice-to-haves that aren't present in curses, and probably never will be.
16
+ Note that while Notcurses will be familiar to anyone who has worked with
17
+ curses, it is not a drop-in replacement. The API is definitely different.
18
+
19
+ https://github.com/dankamongmen/notcurses
20
+
21
+ ## Installation
22
+
23
+ You should install swig first via your OS package management system. If swig
24
+ can't be found, the default generated code will be used which was generated on
25
+ a modern Linux system (Ubuntu 22 LTS).
26
+
27
+ Otherwise it's just your typical gem install notcurses.
28
+
29
+ ## Usage
30
+
31
+ This is JUST the extension- which puts all the functions and constants under
32
+ the Notcurses namespace. I will be developing a more idiomatic object model to
33
+ interface with this in a separate project, which gives you the freedom to
34
+ choose the raw extension or the full on object-oriented style.
35
+
36
+ ## Developing
37
+
38
+ Everything is pretty much in ext. The swig interface (notcurses.i) is the main
39
+ thing, with a couple of overridden/wrapper functions for things that take
40
+ va_list args cause swig doesn't yet have a built-in facility to translating
41
+ from ruby's variadics to va_list. The notcurses_wrap.c is what SWIG auto-
42
+ generates. It's committed to the repo just as a fallback if SWIG isn't in-
43
+ stalled on the local machine but that isn't really a great idea anyways.
44
+
45
+ If you are new to curses stuff, you will need to be reminded that you will
46
+ need to use pry-remote to debug since the terminal will be controlled by
47
+ notcurses.
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/slithernix/notcurses.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
17
+
@@ -0,0 +1,269 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ V0 = $(V:0=)
7
+ Q1 = $(V:1=)
8
+ Q = $(Q1:0=@)
9
+ ECHO1 = $(V:1=@ :)
10
+ ECHO = $(ECHO1:0=@ echo)
11
+ NULLCMD = :
12
+
13
+ #### Start of system configuration section. ####
14
+
15
+ srcdir = .
16
+ topdir = /usr/local/rvm/rubies/ruby-3.2.0/include/ruby-3.2.0
17
+ hdrdir = $(topdir)
18
+ arch_hdrdir = /usr/local/rvm/rubies/ruby-3.2.0/include/ruby-3.2.0/x86_64-linux
19
+ PATH_SEPARATOR = :
20
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
21
+ prefix = $(DESTDIR)/usr/local/rvm/rubies/ruby-3.2.0
22
+ rubysitearchprefix = $(rubylibprefix)/$(sitearch)
23
+ rubyarchprefix = $(rubylibprefix)/$(arch)
24
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
25
+ exec_prefix = $(prefix)
26
+ vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
27
+ sitearchhdrdir = $(sitehdrdir)/$(sitearch)
28
+ rubyarchhdrdir = $(rubyhdrdir)/$(arch)
29
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
30
+ sitehdrdir = $(rubyhdrdir)/site_ruby
31
+ rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
32
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
33
+ vendorlibdir = $(vendordir)/$(ruby_version)
34
+ vendordir = $(rubylibprefix)/vendor_ruby
35
+ sitearchdir = $(sitelibdir)/$(sitearch)
36
+ sitelibdir = $(sitedir)/$(ruby_version)
37
+ sitedir = $(rubylibprefix)/site_ruby
38
+ rubyarchdir = $(rubylibdir)/$(arch)
39
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
40
+ sitearchincludedir = $(includedir)/$(sitearch)
41
+ archincludedir = $(includedir)/$(arch)
42
+ sitearchlibdir = $(libdir)/$(sitearch)
43
+ archlibdir = $(libdir)/$(arch)
44
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
45
+ mandir = $(datarootdir)/man
46
+ localedir = $(datarootdir)/locale
47
+ libdir = $(exec_prefix)/lib
48
+ psdir = $(docdir)
49
+ pdfdir = $(docdir)
50
+ dvidir = $(docdir)
51
+ htmldir = $(docdir)
52
+ infodir = $(datarootdir)/info
53
+ docdir = $(datarootdir)/doc/$(PACKAGE)
54
+ oldincludedir = $(DESTDIR)/usr/include
55
+ includedir = $(prefix)/include
56
+ runstatedir = $(localstatedir)/run
57
+ localstatedir = $(prefix)/var
58
+ sharedstatedir = $(prefix)/com
59
+ sysconfdir = $(DESTDIR)/etc
60
+ datadir = $(datarootdir)
61
+ datarootdir = $(prefix)/share
62
+ libexecdir = $(exec_prefix)/libexec
63
+ sbindir = $(exec_prefix)/sbin
64
+ bindir = $(exec_prefix)/bin
65
+ archdir = $(rubyarchdir)
66
+
67
+
68
+ CC_WRAPPER =
69
+ CC = gcc
70
+ CXX = g++
71
+ LIBRUBY = $(LIBRUBY_SO)
72
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
73
+ LIBRUBYARG_SHARED = -Wl,-rpath,'$${ORIGIN}/../lib' -Wl,-rpath,'$${ORIGIN}/../lib' -l$(RUBY_SO_NAME)
74
+ LIBRUBYARG_STATIC = -Wl,-rpath,'$${ORIGIN}/../lib' -Wl,-rpath,'$${ORIGIN}/../lib' -l$(RUBY_SO_NAME)-static $(MAINLIBS)
75
+ empty =
76
+ OUTFLAG = -o $(empty)
77
+ COUTFLAG = -o $(empty)
78
+ CSRCFLAG = $(empty)
79
+
80
+ RUBY_EXTCONF_H =
81
+ cflags = $(optflags) $(debugflags) $(warnflags)
82
+ cxxflags =
83
+ optflags = -O3 -fno-fast-math
84
+ debugflags = -ggdb3
85
+ warnflags = -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef
86
+ cppflags =
87
+ CCDLFLAGS = -fPIC
88
+ CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC -I/usr/include/notcurses $(ARCH_FLAG)
89
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
90
+ DEFS =
91
+ CPPFLAGS = $(DEFS) $(cppflags)
92
+ CXXFLAGS = $(CCDLFLAGS) $(ARCH_FLAG)
93
+ ldflags = -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed
94
+ dldflags = -Wl,--compress-debug-sections=zlib
95
+ ARCH_FLAG =
96
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
97
+ LDSHARED = $(CC) -shared
98
+ LDSHAREDXX = $(CXX) -shared
99
+ AR = gcc-ar
100
+ EXEEXT =
101
+
102
+ RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
103
+ RUBY_SO_NAME = ruby
104
+ RUBYW_INSTALL_NAME =
105
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
106
+ RUBYW_BASE_NAME = rubyw
107
+ RUBY_BASE_NAME = ruby
108
+
109
+ arch = x86_64-linux
110
+ sitearch = $(arch)
111
+ ruby_version = 3.2.0
112
+ ruby = $(bindir)/$(RUBY_BASE_NAME)
113
+ RUBY = $(ruby)
114
+ BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME)
115
+ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
116
+
117
+ RM = rm -f
118
+ RM_RF = rm -fr
119
+ RMDIRS = rmdir --ignore-fail-on-non-empty -p
120
+ MAKEDIRS = /usr/bin/mkdir -p
121
+ INSTALL = /usr/bin/install
122
+ INSTALL_PROG = $(INSTALL) -m 0755
123
+ INSTALL_DATA = $(INSTALL) -m 644
124
+ COPY = cp
125
+ TOUCH = exit >
126
+
127
+ #### End of system configuration section. ####
128
+
129
+ preload =
130
+ libpath = . $(libdir)
131
+ LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir)
132
+ DEFFILE =
133
+
134
+ CLEANFILES = mkmf.log
135
+ DISTCLEANFILES =
136
+ DISTCLEANDIRS =
137
+
138
+ extout =
139
+ extout_prefix =
140
+ target_prefix =
141
+ LOCAL_LIBS =
142
+ LIBS = $(LIBRUBYARG_SHARED) -lnotcurses-core -lnotcurses -lm -lpthread -lc
143
+ ORIG_SRCS = ncplane_vprintf_aligned.c ncplane_vprintf_stained.c ncplane_vprintf_yx.c notcurses_wrap.c
144
+ SRCS = $(ORIG_SRCS) ncplane_vprintf_aligned.c ncplane_vprintf_stained.c ncplane_vprintf_yx.c notcurses_wrap.c
145
+ OBJS = ncplane_vprintf_aligned.o ncplane_vprintf_stained.o ncplane_vprintf_yx.o notcurses_wrap.o
146
+ HDRS = $(srcdir)/notcurses_wrapper.h
147
+ LOCAL_HDRS =
148
+ TARGET = notcurses
149
+ TARGET_NAME = notcurses
150
+ TARGET_ENTRY = Init_$(TARGET_NAME)
151
+ DLLIB = $(TARGET).so
152
+ EXTSTATIC =
153
+ STATIC_LIB =
154
+
155
+ TIMESTAMP_DIR = .
156
+ BINDIR = $(bindir)
157
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
158
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
159
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
160
+ HDRDIR = $(sitehdrdir)$(target_prefix)
161
+ ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix)
162
+ TARGET_SO_DIR =
163
+ TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
164
+ CLEANLIBS = $(TARGET_SO) false
165
+ CLEANOBJS = $(OBJS) *.bak
166
+ TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.time
167
+
168
+ all: $(DLLIB)
169
+ static: $(STATIC_LIB)
170
+ .PHONY: all install static install-so install-rb
171
+ .PHONY: clean clean-so clean-static clean-rb
172
+
173
+ clean-static::
174
+ clean-rb-default::
175
+ clean-rb::
176
+ clean-so::
177
+ clean: clean-so clean-static clean-rb-default clean-rb
178
+ -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
179
+
180
+ distclean-rb-default::
181
+ distclean-rb::
182
+ distclean-so::
183
+ distclean-static::
184
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
185
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
186
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
187
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
188
+
189
+ realclean: distclean
190
+ install: install-so install-rb
191
+
192
+ install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP)
193
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
194
+ clean-static::
195
+ -$(Q)$(RM) $(STATIC_LIB)
196
+ install-rb: pre-install-rb do-install-rb install-rb-default
197
+ install-rb-default: pre-install-rb-default do-install-rb-default
198
+ pre-install-rb: Makefile
199
+ pre-install-rb-default: Makefile
200
+ do-install-rb:
201
+ do-install-rb-default:
202
+ pre-install-rb-default:
203
+ @$(NULLCMD)
204
+ $(TARGET_SO_DIR_TIMESTAMP):
205
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
206
+ $(Q) $(TOUCH) $@
207
+
208
+ site-install: site-install-so site-install-rb
209
+ site-install-so: install-so
210
+ site-install-rb: install-rb
211
+
212
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
213
+
214
+ .cc.o:
215
+ $(ECHO) compiling $(<)
216
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
217
+
218
+ .cc.S:
219
+ $(ECHO) translating $(<)
220
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
221
+
222
+ .mm.o:
223
+ $(ECHO) compiling $(<)
224
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
225
+
226
+ .mm.S:
227
+ $(ECHO) translating $(<)
228
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
229
+
230
+ .cxx.o:
231
+ $(ECHO) compiling $(<)
232
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
233
+
234
+ .cxx.S:
235
+ $(ECHO) translating $(<)
236
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
237
+
238
+ .cpp.o:
239
+ $(ECHO) compiling $(<)
240
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
241
+
242
+ .cpp.S:
243
+ $(ECHO) translating $(<)
244
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
245
+
246
+ .c.o:
247
+ $(ECHO) compiling $(<)
248
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
249
+
250
+ .c.S:
251
+ $(ECHO) translating $(<)
252
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
253
+
254
+ .m.o:
255
+ $(ECHO) compiling $(<)
256
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
257
+
258
+ .m.S:
259
+ $(ECHO) translating $(<)
260
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
261
+
262
+ $(TARGET_SO): $(OBJS) Makefile
263
+ $(ECHO) linking shared-object $(DLLIB)
264
+ -$(Q)$(RM) $(@)
265
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
266
+
267
+
268
+
269
+ $(OBJS): $(HDRS) $(ruby_headers)
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mkmf'
4
+
5
+ #dir_config('notcurses')
6
+
7
+ $srcs = Dir.glob('*.c')
8
+
9
+ # Specify additional include directories
10
+ notcurses_include_path = '/usr/include/notcurses'
11
+
12
+ defines = %w[
13
+ __x86_64__
14
+ __linux__
15
+ _ISbit
16
+ ]
17
+
18
+ include_paths = [
19
+ "/usr/include",
20
+ "/usr/include/linux",
21
+ "/usr/include/c++/11",
22
+ "/usr/include/c++/11/tr1",
23
+ "/usr/include/x86_64-linux-gnu",
24
+ "/usr/include/x86_64-linux-gnu/c++/11",
25
+ notcurses_include_path,
26
+ ]
27
+
28
+ append_cflags("-I#{notcurses_include_path}")
29
+ swig_cmd = "swig -D#{defines.join(' -D')} -ruby -I#{include_paths.join(' -I')} notcurses.i"
30
+ puts "SWIG COMMAND IS #{swig_cmd}"
31
+
32
+ `#{swig_cmd}`
33
+ unless $?.success?
34
+ abort "swig generate command (#{swig_cmd}) failed"
35
+ end
36
+
37
+ # You can add multiple directories if needed
38
+ # append_cflags("-I/path/to/another/include")
39
+
40
+ #include_paths.each do |inc|
41
+ # append_cflags("-I #{inc}")
42
+ #end
43
+ %w[
44
+ direct.h
45
+ nckeys.h
46
+ ncport.h
47
+ ncseqs.h
48
+ notcurses.h
49
+ version.h
50
+ ].each do |header|
51
+ unless find_header(header, *include_paths)
52
+ abort "#{header} is missing. Please install notcurses or notcurses dev package."
53
+ end
54
+ end
55
+
56
+ %w[ notcurses notcurses-core ].each do |lib|
57
+ unless have_library(lib)
58
+ abort "notcurses library is missing. Please install notcurses."
59
+ end
60
+ end
61
+
62
+ # Create Makefile
63
+ create_makefile('notcurses')
@@ -0,0 +1,49 @@
1
+ %{
2
+ #if defined(__linux__)
3
+ #include <endian.h>
4
+ #if BYTE_ORDER == LITTLE_ENDIAN
5
+ #define SWIG_RUBY_ENDIAN "LE"
6
+ #elif BYTE_ORDER == BIG_ENDIAN
7
+ #define SWIG_RUBY_ENDIAN "BE"
8
+ #endif
9
+ #else
10
+ #define SWIG_RUBY_ENDIAN "LE"
11
+ #endif
12
+
13
+ #include "ruby/encoding.h"
14
+
15
+ /**
16
+ * The internal encoding of std::wstring is defined based on
17
+ * the size of wchar_t. If it is not appropriate for your library,
18
+ * SWIG_RUBY_WSTRING_ENCODING must be given when compiling.
19
+ */
20
+ #ifndef SWIG_RUBY_WSTRING_ENCODING
21
+
22
+ #if WCHAR_MAX == 0x7fff || WCHAR_MAX == 0xffff
23
+ #define SWIG_RUBY_WSTRING_ENCODING "UTF-16" SWIG_RUBY_ENDIAN
24
+ #elif WCHAR_MAX == 0x7fffffff || WCHAR_MAX == 0xffffffff
25
+ #define SWIG_RUBY_WSTRING_ENCODING "UTF-32" SWIG_RUBY_ENDIAN
26
+ #else
27
+ #error unsupported wchar_t size. SWIG_RUBY_WSTRING_ENCODING must be given.
28
+ #endif
29
+
30
+ #endif
31
+
32
+ /**
33
+ * If Encoding.default_internal is nil, this encoding will be used
34
+ * when converting from std::wstring to String object in Ruby.
35
+ */
36
+ #ifndef SWIG_RUBY_INTERNAL_ENCODING
37
+ #define SWIG_RUBY_INTERNAL_ENCODING "UTF-8"
38
+ #endif
39
+
40
+ static rb_encoding *swig_ruby_wstring_encoding;
41
+ static rb_encoding *swig_ruby_internal_encoding;
42
+
43
+ %}
44
+
45
+ %fragment("SWIG_ruby_wstring_encoding_init", "init") {
46
+ swig_ruby_wstring_encoding = rb_enc_find( SWIG_RUBY_WSTRING_ENCODING );
47
+ swig_ruby_internal_encoding = rb_enc_find( SWIG_RUBY_INTERNAL_ENCODING );
48
+ }
49
+
@@ -0,0 +1,43 @@
1
+ #include <notcurses/notcurses.h>
2
+ #include <ruby.h>
3
+ #include <stdio.h>
4
+
5
+ int ruby_ncplane_vprintf_aligned(struct ncplane* n, int y, ncalign_e align, const char* format, VALUE rb_args) {
6
+ int argc = RARRAY_LEN(rb_args);
7
+ VALUE* argv = RARRAY_PTR(rb_args);
8
+
9
+ char* buffer = NULL;
10
+ size_t buffer_size = 0;
11
+ FILE* memstream = open_memstream(&buffer, &buffer_size);
12
+ if (!memstream) {
13
+ rb_raise(rb_eRuntimeError, "Failed to create memory stream");
14
+ return -1;
15
+ }
16
+
17
+ for (int i = 0; i < argc; i++) {
18
+ VALUE arg = argv[i];
19
+ switch (TYPE(arg)) {
20
+ case T_FIXNUM:
21
+ fprintf(memstream, format, NUM2INT(arg));
22
+ break;
23
+ case T_FLOAT:
24
+ fprintf(memstream, format, NUM2DBL(arg));
25
+ break;
26
+ case T_STRING:
27
+ fprintf(memstream, format, StringValueCStr(arg));
28
+ break;
29
+ default:
30
+ fclose(memstream);
31
+ free(buffer);
32
+ rb_raise(rb_eTypeError, "Unsupported argument type");
33
+ return -1;
34
+ }
35
+ }
36
+
37
+ fclose(memstream);
38
+
39
+ int result = ncplane_putstr_aligned(n, y, align, buffer);
40
+
41
+ free(buffer);
42
+ return result;
43
+ }
@@ -0,0 +1,43 @@
1
+ #include <notcurses/notcurses.h>
2
+ #include <ruby.h>
3
+ #include <stdio.h>
4
+
5
+ int ruby_ncplane_vprintf_stained(struct ncplane* n, const char* format, VALUE rb_args) {
6
+ int argc = RARRAY_LEN(rb_args);
7
+ VALUE* argv = RARRAY_PTR(rb_args);
8
+
9
+ char* buffer = NULL;
10
+ size_t buffer_size = 0;
11
+ FILE* memstream = open_memstream(&buffer, &buffer_size);
12
+ if (!memstream) {
13
+ rb_raise(rb_eRuntimeError, "Failed to create memory stream");
14
+ return -1;
15
+ }
16
+
17
+ for (int i = 0; i < argc; i++) {
18
+ VALUE arg = argv[i];
19
+ switch (TYPE(arg)) {
20
+ case T_FIXNUM:
21
+ fprintf(memstream, format, NUM2INT(arg));
22
+ break;
23
+ case T_FLOAT:
24
+ fprintf(memstream, format, NUM2DBL(arg));
25
+ break;
26
+ case T_STRING:
27
+ fprintf(memstream, format, StringValueCStr(arg));
28
+ break;
29
+ default:
30
+ fclose(memstream);
31
+ free(buffer);
32
+ rb_raise(rb_eTypeError, "Unsupported argument type");
33
+ return -1;
34
+ }
35
+ }
36
+
37
+ fclose(memstream);
38
+
39
+ int result = ncplane_putstr_stained(n, buffer);
40
+
41
+ free(buffer);
42
+ return result;
43
+ }