Skip to content

Commit

Permalink
Merge pull request #315 from chasonr/os2gui
Browse files Browse the repository at this point in the history
New port -- OS2GUI
  • Loading branch information
Bill-Gray authored Oct 15, 2024
2 parents 8466f73 + 9ff74e9 commit 23b1fbe
Show file tree
Hide file tree
Showing 17 changed files with 9,348 additions and 1 deletion.
3 changes: 2 additions & 1 deletion curses.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ enum PDC_port
PDC_PORT_DOSVGA = 8,
PDC_PORT_PLAN9 = 9,
PDC_PORT_LINUX_FB = 10,
PDC_PORT_OPENGL = 11
PDC_PORT_OPENGL = 11,
PDC_PORT_OS2GUI = 12
};

/* Use this structure with PDC_get_version() for run-time info about the
Expand Down
3 changes: 3 additions & 0 deletions curspriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ int PDC_mbtowc(wchar_t *, const char *, size_t);
size_t PDC_mbstowcs(wchar_t *, const char *, size_t);
size_t PDC_wcstombs(char *, const wchar_t *, size_t);
PDCEX int PDC_wcwidth( const int32_t ucs);
#ifdef USING_COMBINING_CHARACTER_SCHEME
int PDC_expand_combined_characters( const cchar_t c, cchar_t *added);
#endif
#endif

#define MAX_UNICODE 0x110000
Expand Down
1 change: 1 addition & 0 deletions os2gui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pdcurses.lbc
30 changes: 30 additions & 0 deletions os2gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.11)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE)
message(STATUS "No build type specified, defaulting to MinSizeRel.")
endif()

PROJECT(wingui VERSION "${PROJECT_VERSION}" LANGUAGES C)

INCLUDE(project_common)

demo_app(../demos calendar)
demo_app(../demos firework)
demo_app(../demos init_col)
demo_app(../demos mbrot)
demo_app(../demos newtest WIN32)
demo_app(../demos ozdemo)
demo_app(../demos picsview)
demo_app(../demos ptest)
demo_app(../demos rain)
demo_app(../demos speed)
demo_app(../demos test_pan)
demo_app(../demos testcurs)
demo_app(../demos version)
demo_app(../demos widetest)
demo_app(../demos worm)
demo_app(../demos xmas)


SET(CPACK_COMPONENTS_ALL applications)
179 changes: 179 additions & 0 deletions os2gui/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# GNU MAKE Makefile for PDCurses library - WIN32/64/ARM MinGW GCC/LLVM
#
# Usage: [g]make [-f path\Makefile] [DEBUG=Y] [DLL=Y] [WIDE=Y] [UTF8=Y]
# [LIBNAME=(name)] [DLLNAME=(name)] [target]
# [_w32=Y | _w64=Y | _a64=Y ]
#
# where target can be any of:
# [all|demos|pdcurses.a|testcurs.exe...]

O = o
E = .exe

ifndef PDCURSES_SRCDIR
PDCURSES_SRCDIR = ..
endif

osdir = $(PDCURSES_SRCDIR)/os2gui
common = $(PDCURSES_SRCDIR)/common

include $(common)/libobjs.mif

uname_S := $(shell uname -s 2>/dev/null)

CAT = cat
PREFIX =
PATH_SEP = /
CP = cp
RM = rm -f

# It appears we have three cases: we're running in Cygwin/MSYS; or we're
# running in command.com on Windows with MinGW; or we're on Linux or BSD
# or similar system, cross-compiling with MinGW.

ifneq (,$(findstring CYGWIN,$(uname_S)))
# Insert Cygwin-specific changes here
ON_WINDOWS = 1
endif
ifneq (,$(findstring MINGW32_NT,$(uname_S)))
# Insert MINGW32-specific changes here
ON_WINDOWS = 1
endif
ifneq (,$(findstring MINGW64_NT,$(uname_S)))
# Insert MINGW64-specific changes here
ON_WINDOWS = 1
endif

ifeq ($(uname_S),)
CAT = type
PATH_SEP = \\
CP = copy
RM = cmd /c del
ON_WINDOWS = 1
endif

# If we aren't on Windows, assume MinGW on a Linux-like host
# Only decision is: are we doing a 64-bit compile (_w64 defined)?

ifndef ON_WINDOWS
PREFIX = i686-w64-mingw32-
ifdef _w64
PREFIX = x86_64-w64-mingw32-
endif
ifdef _a64
PREFIX = aarch64-w64-mingw32-
endif
endif

PDCURSES_WIN_H = $(osdir)/pdcwin.h

CC = $(PREFIX)gcc

AR = $(PREFIX)ar

CFLAGS += -Wall -pedantic
ifeq ($(DEBUG),Y)
CFLAGS += -g -DPDCDEBUG
LDFLAGS = -g
else
CFLAGS += -O3
LDFLAGS =
endif

CFLAGS += -I$(PDCURSES_SRCDIR)

ifdef CHTYPE_32
CFLAGS += -DCHTYPE_32
endif

ifeq ($(UTF8),Y)
CFLAGS += -DPDC_FORCE_UTF8
else
ifeq ($(WIDE),Y)
CFLAGS += -DPDC_WIDE
endif
endif

LINK = $(CC)
LIBNAME = pdcurses
DLLNAME = pdcurses

ifeq ($(DLL),Y)
CFLAGS += -DPDC_DLL_BUILD
LIBEXE = $(CC)
LIBFLAGS = -Wl,--out-implib,$(LIBNAME).a -static-libgcc -shared -o
LIBCURSES = $(DLLNAME).dll
LIBDEPS = $(LIBOBJS) $(PDCOBJS)
LIBSADDED = -lgdi32 -lcomdlg32 -lwinmm
EXELIBS =
CLEAN = $(LIBCURSES) *.a
else
LIBEXE = $(AR)
ifeq ($(PREFIX),)
LIBFLAGS = rcv
else
LIBFLAGS = rv
endif
LIBCURSES = $(LIBNAME).a
LIBDEPS = $(LIBOBJS) $(PDCOBJS)
LIBSADDED =
EXELIBS =
CLEAN = *.a
endif

.PHONY: all libs clean demos dist

all: libs

libs: $(LIBCURSES)

clean:
-$(RM) *.o
-$(RM) *.exe
-$(RM) *.dll
-$(RM) $(CLEAN)

demos: $(DEMOS)

$(LIBCURSES) : $(LIBDEPS)
$(LIBEXE) $(LIBFLAGS) $@ $? $(LIBSADDED)
$(CP) $(LIBNAME).a panel.a

$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
$(PDCOBJS) : $(PDCURSES_WIN_H)
$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
panel.o : $(PANEL_HEADER)

$(LIBOBJS) : %.o: $(srcdir)/%.c
$(CC) -c $(CFLAGS) $<

$(PDCOBJS) : %.o: $(osdir)/%.c
$(CC) -c $(CFLAGS) $<

calendar.exe firework.exe init_col.exe mbrot.exe \
newtest.exe ozdemo.exe picsview.exe \
ptest.exe rain.exe speed.exe testcurs.exe test_pan.exe \
version.exe widetest.exe worm.exe xmas.exe: %.exe: $(demodir)/%.c
$(CC) $(CFLAGS) -o $@ $< $(LIBCURSES) $(EXELIBS)
emxbind -ep $@

tuidemo.exe: tuidemo.o tui.o
$(LINK) $(LDFLAGS) -o $@ tuidemo.o tui.o $(LIBCURSES) $(EXELIBS)
emxbind -ep $@

tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
$(CC) -c $(CFLAGS) -I$(demodir) -o $@ $<

tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
$(CC) -c $(CFLAGS) -I$(demodir) -o $@ $<

configure :
$(CC) $(CFLAGS) -o config_curses$(E) $(common)/config_curses.c
ifdef ON_WINDOWS
config_curses$(E) -v -d.. $(CFLAGS)
else
wine config_curses$(E) -v -d.. $(CFLAGS)
endif
rm config_curses$(E)

include $(PDCURSES_SRCDIR)/demos/nctests.mif
32 changes: 32 additions & 0 deletions os2gui/Makefile.wcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Watcom WMAKE Makefile for PDCurses library - OS/2 Watcom C/C++
#
# Usage: wmake -f [wingui/]Makefile.wcc [DEBUG=Y] [WIDE=Y] [UTF8=Y] [target]
#
# where target can be any of:
# [all|demos|pdcurses.lib|testcurs.exe...]

!ifdef %PDCURSES_SRCDIR
PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
!else
PDCURSES_SRCDIR = ..
!endif

common = $(PDCURSES_SRCDIR)/common

osdir = os2gui

TARGET = os2

LTARGET = os2v2_pm

CFLAGS = -ei

!ifeq DLL Y
ADDED_LIBS_FOR_DLL =
!else
ADDED_LIBS =
!endif

EXTRA_LIB_CMD = -$(COPY) $(PDCNAME).lib panel.lib

!include $(common)/watcom.mif
69 changes: 69 additions & 0 deletions os2gui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
PDCurses for OS2GUI
===================

This directory contains PDCurses source code files specific to OS/2
graphics mode.

Building
--------

- Choose the appropriate makefile for your compiler:

Makefile - EMX 0.9d+
Makefile.wcc - Open Watcom 1.9+

- Optionally, you can build in a different directory than the platform
directory by setting PDCURSES_SRCDIR to point to the directory where
you unpacked PDCurses, and changing to your target directory:

set PDCURSES_SRCDIR=c:\pdcurses

- Build it:

make -f makefilename

(For Watcom, use "wmake" instead of "make"; for MSVC, "nmake".) You'll
get the libraries (pdcurses.lib or .a, depending on your compiler; and
panel.lib or .a), the demos (*.exe), and a lot of object files. Note
that the panel library is just a copy of the main library, provided
for convenience; both panel and curses functions are in the main
library.

You can also give the optional parameter "WIDE=Y", to build the
library with wide-character (Unicode) support:

wmake -f Makefile.wcc WIDE=Y

Another option, "UTF8=Y", makes PDCurses ignore the system locale, and
treat all narrow-character strings as UTF-8. This option has no effect
unless WIDE=Y is also set. This was originally provided to get around
poor support for UTF-8 in the Win32 console:

wmake -f Makefile.wcc WIDE=Y UTF8=Y

OS2GUI doesn't have the same limitations as the OS/2 console flavor,
but UTF-8 and non-UTF-8 versions are still available. If nothing else,
this means that if you've built a OS/2 console PDCurses DLL with any
configuration, you can build a matching OS2GUI DLL and swap between
console or GUI PDCurses just by swapping DLLs.

You can also use the optional parameter "DLL=Y" with Visual C++,
MinGW or Cygwin, to build the library as a DLL:

nmake -f Makefile.vc WIDE=Y DLL=Y

When you build the library as a Windows DLL, you must always define
PDC_DLL_BUILD when linking against it. (Or, if you only want to use
the DLL, you could add this definition to your curses.h.)

Distribution Status
-------------------

The files in this directory are released to the Public Domain.

Acknowledgements
----------------

Based heavily on the Win32 console flavor of PDCurses by Chris Szurgot
<szurgot[at]itribe.net>, ported to Win32 GUI by Bill Gray
<pluto[at]projectpluto.com>.
Loading

0 comments on commit 23b1fbe

Please sign in to comment.