Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This software is provided AS IS with NO WARRANTY whatsoever.
Ports
-----

PDCurses has been ported to DOS, OS/2, Win32, X11 and SDL1 and SDL2,
PDCurses has been ported to DOS, OS/2, Plan9, Win32, X11 and SDL1 and SDL2,
and this version adds a Windows graphical and VT-like console
flavor. A directory containing the port-specific source files exists
for each of these platforms.
Expand All @@ -43,6 +43,7 @@ Build instructions are in the README file for each platform:

- [DOS](dos/README.md) for use on DOS
- [OS/2](os2/README.md) for use on OS/2
- [Plan9](plan9/README.md) for use on Plan9 (APE)
- [SDL 1.x](sdl1/README.md) for use as separate SDL version 1 window
- [SDL 2.x](sdl2/README.md) for use as separate SDL version 2 window
- [wincon](wincon/README.md) (formerly win32) for use on Windows Console
Expand Down
3 changes: 2 additions & 1 deletion curses.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ enum PDC_port
PDC_PORT_SDL1 = 5,
PDC_PORT_SDL2 = 6,
PDC_PORT_VT = 7,
PDC_PORT_DOSVGA = 8
PDC_PORT_DOSVGA = 8,
PDC_PORT_PLAN9 = 9
};

/* Use this structure with PDC_get_version() for run-time info about the
Expand Down
3 changes: 3 additions & 0 deletions demos/picsview.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#define CONVERT_IMAGES
#include <unistd.h>
#endif
#if defined(Plan9)
#include <unistd.h>
#endif

/* This is inspired by, but not really based on, Thomas E. Dickey's
'picsmap' program for ncurses. Its real purpose is to demonstrate the
Expand Down
1 change: 0 additions & 1 deletion demos/speed.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <stdio.h>
#include <wchar.h>
#include <curses.h>

/* ftime() is consided obsolete. But it's all we have for
Expand Down
57 changes: 57 additions & 0 deletions plan9/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
PDCurses for Plan9
==================

This directory contains PDCurses source code files specific to Plan9.


Building
--------

- cd to the plan9 sub directory

- Build it:

mk
mk install

- Optionally, you can cross compile by setting the variable $objtype,
for example:

objtype=amd64 mk

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

Copyright (c) 2007 Federico G. Benavento

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Federico G. Benavento
January 2008
benavento@gmail.com


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

Federico G. Benavento made the original port to PDCurses 3.0

Jens Staal updated it

11 changes: 11 additions & 0 deletions plan9/header.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- curses.h 2020-06-29 15:03:16.675718137 +0200
+++ curses.h.ape 2020-06-29 19:09:31.624238344 +0200
@@ -5,6 +5,8 @@
#ifndef __PDCURSES__
#define __PDCURSES__ 1

+#pragma lib "/$M/lib/ape/libcurses.a"
+
/*man-start**************************************************************

Define before inclusion (only those needed):
100 changes: 100 additions & 0 deletions plan9/mkfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
</$objtype/mkfile

LIB=libcurses.a

OFILES=\
# pdcurses \
addch.$O\
addchstr.$O\
addstr.$O\
attr.$O\
beep.$O\
bkgd.$O\
border.$O\
clear.$O\
color.$O\
debug.$O\
delch.$O\
deleteln.$O\
getch.$O\
getstr.$O\
getyx.$O\
inch.$O\
inchstr.$O\
initscr.$O\
inopts.$O\
insch.$O\
insstr.$O\
instr.$O\
kernel.$O\
keyname.$O\
mouse.$O\
move.$O\
outopts.$O\
overlay.$O\
pad.$O\
panel.$O\
printw.$O\
refresh.$O\
scanw.$O\
scr_dump.$O\
scroll.$O\
slk.$O\
termattr.$O\
touch.$O\
util.$O\
window.$O\
# plan9 \
pdcclip.$O\
pdcdisp.$O\
pdcgetsc.$O\
pdckbd.$O\
pdcscrn.$O\
pdcsetsc.$O\
pdcutil.$O

HFILES=\
/sys/include/ape/curses.h\
/sys/include/ape/panel.h\

UPDATE=\
mkfile\
$HFILES\
${OFILES:%.$O=%.c}\
${LIB:/$objtype/%=/386/%}\

</sys/src/cmd/mksyslib

CC=pcc
LD=pcc
CFLAGS= -c -I. -I.. -D_POSIX_SOURCE -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION \
-DHAVE_VSNPRINTF

%.$O: ../pdcurses/%.c
$CC $CFLAGS ../pdcurses/$stem.c

%.$O: %.c
$CC $CFLAGS $stem.c


install:V:
cp libcurses.a /$objtype/lib/ape/libcurses.a
cp ../curses.h /sys/include/ape/curses.h
ape/patch /sys/include/ape/curses.h <header.patch
cp ../panel.h /sys/include/ape/panel.h

demos:V:
@{
mk -f mkfile_demo all
}

clean:V:
@{
mk -f mkfile_demo clean
}
rm -f *.[$OS]

nuke:V:
rm -f $LIB
rm -f /$objtype/lib/ape/libcurses.a
rm -f $HFILES
36 changes: 36 additions & 0 deletions plan9/mkfile_demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
APE=/sys/src/ape
<$APE/config

TARG=\
firework\
newtest\
ozdemo\
picsview\
ptest\
rain\
speed\
testcurs\
tuidemo\
worm\
xmas\

HFILES=\
/sys/include/ape/curses.h\
/sys/include/ape/panel.h\

UPDATE=\
mkfile\
$HFILES\
${OFILES:%.$O=%.c}\
/$objtype/ape/lib/libcurses.a

</sys/src/cmd/mkmany

CFLAGS= -c -D_POSIX_SOURCE -D_BSD_EXTENSION -D_SUSV2_SOURCE -DPlan9

%.$O: ../demos/%.c
$CC $CFLAGS ../demos/$stem.c

$O.tuidemo:V: tui.$O tuidemo.$O
$LD -o $target $prereq

67 changes: 67 additions & 0 deletions plan9/pdcclip.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <stdlib.h>
#include <string.h>
#include <curspriv.h>
#include "pdcplan9.h"


static char *clip = NULL;

int PDC_getclipboard(char **sp, long *np)
{
long n;

PDC_LOG(("PDC_getclipboard() - called\n"));
if (!clip)
return PDC_CLIP_EMPTY;

n = strlen(clip);
if ((*sp = malloc(n + 1)) == NULL)
return PDC_CLIP_MEMORY_ERROR;

memmove(*sp, clip, n);
*np = n;

return PDC_CLIP_SUCCESS;
}


int PDC_setclipboard(const char *s, long n)
{
PDC_LOG(("PDC_setclipboard() - called\n"));
if (clip)
{
free(clip);
clip = NULL;
}
if (s)
{
if ((clip = malloc(n + 1)) == NULL)
return PDC_CLIP_MEMORY_ERROR;
memmove(clip, s, n);
clip[n] = 0;
}

return PDC_CLIP_SUCCESS;
}


int PDC_freeclipboard(char *s)
{
PDC_LOG(("PDC_freeclipboard() - called\n"));
free(s);

return PDC_CLIP_SUCCESS;
}


int PDC_clearclipboard(void)
{
PDC_LOG(("PDC_clearclipboard() - called\n"));
if (clip)
{
free(clip);
clip = NULL;
}

return PDC_CLIP_SUCCESS;
}
65 changes: 65 additions & 0 deletions plan9/pdcdisp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <curspriv.h>
#include "pdcplan9.h"

#ifdef CHTYPE_LONG
# define A(x) ((chtype)x | A_ALTCHARSET)
chtype acs_map[128] = {
A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9),
A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27),
A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
'\'', '(', ')', '*',

0x2192, 0x2190, 0x2191, 0x2193,

'/',

0x2588,

'1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
'>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',

0x25c6, 0x2592,

'b', 'c', 'd', 'e',

0x00ba, 0x00b1, 0x0023, 0x0023, 0x2518, 0x2510, 0x250c, 0x2514,
0x253c, 'o',
'p', 0x2500, 'r', 's', 0x2524, 0x251c, 0x2534, 0x252c, 0x2502,
0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x2022,

A(127)
};

# undef A
#endif


void PDC_gotoyx(int y, int x)
{
chtype *ch;

PDC_LOG(("PDC_gotoyx() - called: y %d x %d\n", y, x));
p9setcur(SP->cursrow, SP->curscol, y, x, SP->visibility);
}


void PDC_transform_line(int y, int x, int len, const chtype * srcp)
{
int i;

PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
for (i = 0; i < len; i++)
{
p9putc(y, x + i, srcp[i]);
}
}

void PDC_doupdate(void)
{
p9napms(1);
}


Loading