Skip to content

Commit

Permalink
- Initial working port to PDCurses. Ncurses works as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoore committed Feb 21, 2020
1 parent 70bb474 commit ad6d563
Show file tree
Hide file tree
Showing 15 changed files with 755 additions and 183 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ simple
*.su
*.idb
*.pdb
.vscode

# Kernel Module Compile Results
*.mod*
Expand All @@ -55,6 +56,7 @@ Mkfile.old
dkms.conf
pspg

/autom4te.cache/**
/config.cache
/config.log
/config.status
Expand Down
58 changes: 42 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
all: libst_menu.so libst_menu.a demoapp demoapp_sl simple
all: libst_menu.so libst_menu.a simple demoapp demoapp_sl

# possible to use gcc flag -DNCURSES_WIDECHAR=1 where is possible
# then any unicode char can be a accelerator
Expand All @@ -16,29 +16,56 @@ PKG_CONFIG_PATH = `$(PKG_CONFIG) --variable pc_path pkg-config|cut -d: -f1`
PKG_CONFIG_TARGET = st_menu.pc.install
endif

INCDIRS += $(PDCURSES_INCDIR) include .
LIBDIRS += $(PDCURSES_LIBDIR) .
DEPLIBS += $(PDCURSES_DEP_LIBS)

ifeq ($(HAVE_PDCURSES),yes)
PDCURSES_STATIC_LIB = $(PDCURSES_LIBDIR)/lib$(PDCURSES_LIB).a
PDCURSES_DYN_LIB = $(PDCURSES_LIBDIR)/lib$(PDCURSES_LIB).so
else
# This is required only for the shared lib implementation
# because by default the panel lib is defined too early
# in the list of dependant libs/obejcts. Might be another
# solution but this seems to work.
NCURSES_PANEL_LIB = -lpanel
endif

ST_INCDIRS := $(foreach incdir,$(INCDIRS),-I$(incdir))
ST_LIBDIRS := $(foreach librarydir,$(LIBDIRS),-L$(librarydir))
ST_DEPLIBS := $(foreach library,$(DEPLIBS),-l$(library))

st_menu_styles.o: src/st_menu_styles.c include/st_menu.h
$(CC) -fPIC src/st_menu_styles.c -o st_menu_styles.o -Wall -c -Iinclude $(CFLAGS)
@printf "\nBuilding: $<...\n"
$(CC) -fPIC src/st_menu_styles.c -o st_menu_styles.o -Wall -c $(ST_INCDIRS) $(CFLAGS)

unicode.o: src/unicode.h src/unicode.c
$(CC) -fPIC src/unicode.c -o unicode.o -Wall -c -Iinclude $(CFLAGS)
@printf "\nBuilding: $@...\n"
$(CC) -fPIC src/unicode.c -o unicode.o -Wall -c $(ST_INCDIRS) $(CFLAGS)

st_menu.o: include/st_menu.h src/st_menu.c
$(CC) -fPIC src/st_menu.c -o st_menu.o -c -O3 -g $(CFLAGS) -Iinclude -I.
@printf "\nBuilding: $@...\n"
$(CC) -fPIC src/st_menu.c -o st_menu.o -c -O3 -g $(CFLAGS) $(ST_INCDIRS)

libst_menu.so: st_menu_styles.o st_menu.o $(UNICODE_OBJ)
$(CC) -shared -Wl,-soname,libst_menu.so -o libst_menu.so st_menu.o st_menu_styles.o $(UNICODE_OBJ) -Iinclude $(CFLAGS)
@printf "\nBuilding: $@...\n"
$(CC) -shared -Wl,-soname,libst_menu.so -o libst_menu.so st_menu.o st_menu_styles.o $(PDCURSES_DYN_LIB) $(UNICODE_OBJ) $(ST_INCDIRS) $(CFLAGS)

libst_menu.a: st_menu_styles.o st_menu.o $(UNICODE_OBJ)
@printf "\nBuilding: $@...\n"
$(AR) rcs libst_menu.a st_menu_styles.o st_menu.o $(UNICODE_OBJ)

demoapp: demo/demo.c libst_menu.so libst_menu.a include/st_menu.h
$(CC) demo/demo.c -o demoapp libst_menu.a -Wall $(LDLIBS) -Iinclude $(CFLAGS)
@printf "\nBuilding: $@...\n"
$(CC) demo/demo.c -o demoapp libst_menu.a $(PDCURSES_STATIC_LIB) -Wall $(ST_LIBDIRS) $(LDLIBS) $(ST_DEPLIBS) $(ST_INCDIRS) $(CFLAGS)

demoapp_sl: demo/demo.c libst_menu.so libst_menu.a include/st_menu.h
$(CC) demo/demo.c -o demoapp_sl $(UNICODE_OBJ) -Wall $(LDLIBS) -Iinclude -L. -lst_menu $(CFLAGS)
@printf "\nBuilding: $@...\n"
$(CC) demo/demo.c -o demoapp_sl $(UNICODE_OBJ) $(PDCURSES_STATIC_LIB) -Wall $(ST_LIBDIRS) $(LDLIBS) $(ST_DEPLIBS) $(ST_INCDIRS) $(ST_LIBDIRS) -lst_menu $(NCURSES_PANEL_LIB) $(CFLAGS)

simple: demo/simple.c libst_menu.a include/st_menu.h
$(CC) demo/simple.c -o simple libst_menu.a -Wall $(LDLIBS) $(LIB_UNISTRING) -Iinclude
@printf "\nBuilding: $@...\n"
$(CC) demo/simple.c -o simple libst_menu.a $(PDCURSES_STATIC_LIB) -Wall $(LDLIBS) $(ST_DEPLIBS) $(ST_INCDIRS) $(CFLAGS)

st_menu.pc.install:
tools/install.sh data st_menu.pc $(PKG_CONFIG_PATH)
Expand All @@ -49,11 +76,10 @@ install: libst_menu.so libst_menu.a $(PKG_CONFIG_TARGET)
tools/install.sh bin libst_menu.a $(LIBDIR)

clean:
rm st_menu_styles.o
rm st_menu.o
rm libst_menu.so
rm libst_menu.a
rm demoapp
rm demoapp_sl
rm simple
test -f unicode.o && rm unicode.o || true
rm -f *.o *.a *.so
test -f demoapp && rm demoapp || true
test -f demoapp_sl && rm demoapp_sl || true
test -f simple && rm simple || true

cleanconfig:
rm -f *.file config.log config.make config.status st_menu.pc *.awk
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,88 @@
# Reason for Fork

The main goal of the fork was to make the code compatible with [PDcurses](https://github.com/wmcbrine/PDCurses).

Some changes are:
- consolidated the inclusion of the curses/panel headers
- add a couple #defines to add ncurses APIs missing from PDcurses
- changed `st_menu.c` so to use `newwin2` which has been created to better handle windows that are out of the screen size. PDCurses will not allocate the window which causes crashes--ncurses appears to allocate the window just fine.
- since this a pdcurses fork, there are additional configure arguments needed (see below)
- removed some generated files from the github repo


## Building PDCurses

This is a simple overview on building PDcurses from source. For the latest info refer to the SDL repo/README files.

### X11

```
cd PDCurses/x11
./configure
make
```




## Building for PDCurses

To build for PDCurses you need to first need some added agruments for the `configure` prior to the make. The configure options are defined as:

PDCURSES_INSTALL If you have the PDCurses libs/headers installed you can
simple use just this flag. The other options will be
filled in for you. Currently support: "x11"
NOTE: Other arguments not needed.
PDCURSES_INCDIR Directory containing the curses/panel headers
PDCURSES_LIBDIR Directory containing the PDCurses library
PDCURSES_LIB Name of the PDCurses library, defaults to 'XCurses'
PDCURSES_DEP_LIBS List of the PDCurses dependant library (exclude PDCURSES_LIB),
'XCurses' is already handled.

NOTE: If you are pointing to the PDCurses github directory built for
a specific OS/terminal you can omit the PDCURSES_INCDIR.


This example builds from installed PDCurses for X11:
NOTE: The build tools will setup all the other `PDCURSES_xxx` arguments for us.

```
PDCURSES_INSTALL=x11 ./configure
make
```

This example builds from PDCurses source for X11:
NOTE: PDCURSES_LIB defaults to XCurses so we don't need to specify it

```
PDCURSES_LIBDIR=/home/username/github/PDCurses/x11 ./configure
make
```

This is a complete example (ignores the fact that some variables are not needed:
```
PDCURSES_LIBDIR=/home/username/github/PDCurses/x11 \
PDCURSES_INCDIR=/home/username/github/PDCurses \
PDCURSES_LIB=XCurses \
PDCURSES_DEP_LIBS=Xaw Xmu Xt X11 Xpm SM ICE Xext \
./configure
make
```

NOTE: To generate a debug build append `--enable-debug` to the configure statement.

## Building for NCurses

This assumes the NCurses library/headers are installed:
NOTE: Unlike the PDCurses build, the `configure` needs nothing special (for most cases)

```
./configure
make
```

-----------------------

# ncurses-st-menu

modern and simple ncurses based library for CUA look menu
Expand Down
91 changes: 12 additions & 79 deletions aclocal.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
# generated automatically by aclocal 1.15 -*- Autoconf -*-

# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.

# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand All @@ -13,7 +13,7 @@

m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
# iconv.m4 serial 19 (gettext-0.18.2)
dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc.
dnl Copyright (C) 2000-2002, 2007-2014 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
Expand Down Expand Up @@ -285,7 +285,7 @@ size_t iconv();
])

# lib-ld.m4 serial 6
dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc.
dnl Copyright (C) 1996-2003, 2009-2015 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
Expand Down Expand Up @@ -405,7 +405,7 @@ AC_LIB_PROG_LD_GNU
])

# lib-link.m4 serial 26 (gettext-0.18.2)
dnl Copyright (C) 2001-2016 Free Software Foundation, Inc.
dnl Copyright (C) 2001-2015 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
Expand Down Expand Up @@ -1183,7 +1183,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
])

# lib-prefix.m4 serial 7 (gettext-0.18)
dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc.
dnl Copyright (C) 2001-2005, 2008-2015 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
Expand Down Expand Up @@ -1407,9 +1407,9 @@ sixtyfour bits
test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
])

# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 11 (pkg-config-0.29.1)

dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
dnl serial 11 (pkg-config-0.29.1)
dnl
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
dnl
Expand Down Expand Up @@ -1683,75 +1683,7 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR

dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
dnl [DESCRIPTION], [DEFAULT])
dnl ------------------------------------------
dnl
dnl Prepare a "--with-" configure option using the lowercase
dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
dnl PKG_CHECK_MODULES in a single macro.
AC_DEFUN([PKG_WITH_MODULES],
[
m4_pushdef([with_arg], m4_tolower([$1]))
m4_pushdef([description],
[m4_default([$5], [build with ]with_arg[ support])])
m4_pushdef([def_arg], [m4_default([$6], [auto])])
m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
m4_case(def_arg,
[yes],[m4_pushdef([with_without], [--without-]with_arg)],
[m4_pushdef([with_without],[--with-]with_arg)])
AC_ARG_WITH(with_arg,
AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
[AS_TR_SH([with_]with_arg)=def_arg])
AS_CASE([$AS_TR_SH([with_]with_arg)],
[yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
[auto],[PKG_CHECK_MODULES([$1],[$2],
[m4_n([def_action_if_found]) $3],
[m4_n([def_action_if_not_found]) $4])])
m4_popdef([with_arg])
m4_popdef([description])
m4_popdef([def_arg])
])dnl PKG_WITH_MODULES

dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
dnl [DESCRIPTION], [DEFAULT])
dnl -----------------------------------------------
dnl
dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
dnl check._[VARIABLE-PREFIX] is exported as make variable.
AC_DEFUN([PKG_HAVE_WITH_MODULES],
[
PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
AM_CONDITIONAL([HAVE_][$1],
[test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
])dnl PKG_HAVE_WITH_MODULES

dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
dnl [DESCRIPTION], [DEFAULT])
dnl ------------------------------------------------------
dnl
dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
dnl and preprocessor variable.
AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
[
PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
])dnl PKG_HAVE_DEFINE_WITH_MODULES

# Copyright (C) 2011-2017 Free Software Foundation, Inc.
# Copyright (C) 2011-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -1813,7 +1745,7 @@ AC_SUBST([AR])dnl

# AM_AUX_DIR_EXPAND -*- Autoconf -*-

# Copyright (C) 2001-2017 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -1865,6 +1797,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`

m4_include([tools/absolute-header.m4])
m4_include([tools/ax_debug_cflags.m4])
m4_include([tools/ax_pdcurses.m4])
m4_include([tools/ax_require_defined.m4])
m4_include([tools/ax_with_curses.m4])
m4_include([tools/m4_ax_with_curses_extra.m4])
Expand Down
6 changes: 6 additions & 0 deletions config.make.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ INCLUDEDIR = @includedir@
PKG_CONFIG = @PKG_CONFIG@
HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@

HAVE_PDCURSES = @HAVE_PDCURSES@
PDCURSES_LIB = @PDCURSES_LIB@
PDCURSES_DEP_LIBS = @PDCURSES_DEP_LIBS@
PDCURSES_LIBDIR = @PDCURSES_LIBDIR@
PDCURSES_INCDIR = @PDCURSES_INCDIR@

config.status: configure
./config.status --recheck

Expand Down
Loading

0 comments on commit ad6d563

Please sign in to comment.