Initial commit.

master
Christoph Lohmann 2015-08-27 23:54:58 +02:00
commit b95ee9c3f7
10 changed files with 216 additions and 0 deletions

9
Makefile Normal file
View File

@ -0,0 +1,9 @@
# catpoint
LDLIBS = -lncursesw
BIN = catpoint
all: $(BIN)
clean:
rm -f $(BIN)

10
README Normal file
View File

@ -0,0 +1,10 @@
# Synopsis
Catpoint is a simple viewer of text files written in curses.
Further documentation comes in a series of slides. Just do:
$ make && ./catpoint showoff/*.txt
# Usage
catpoint file ...

103
catpoint.c Normal file
View File

@ -0,0 +1,103 @@
/* $Id: catpoint.c,v 1.2 2013/03/28 12:00:48 lostd Exp $ */
#include <sys/types.h>
#include <sys/mman.h>
#include <err.h>
#include <curses.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
int
main(int argc, char *argv[])
{
int c, i, fd;
char **p; /* the slides */
if (argc == 1)
errx(1, "usage: %s file ...", argv[0]);
argv++;
argc--;
setlocale(LC_ALL, "");
p = calloc(argc, sizeof(char *));
/* map files to mem */
for (i = 0; argv[i] != NULL; i++) {
fd = open(argv[i], O_RDONLY, 0);
if (fd == -1)
err(1, "open: %s", argv[i]);
p[i] = mmap(NULL, 0x1000, PROT_READ, MAP_PRIVATE, fd, 0);
if (p[i] == MAP_FAILED)
err(1, "mmap");
close(fd);
}
/* init curses */
initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
curs_set(FALSE); /* hide cursor */
/* start */
i = 0;
show:
/* display slide */
clear();
printw("%s", p[i]);
again:
c = getch();
switch (c) {
case 'q':
break;
/* next */
case 'l':
case 'j':
case KEY_RIGHT:
case KEY_DOWN:
case KEY_NPAGE:
if (i < argc - 1) {
i++;
goto show;
}
goto again;
/* prev */
case 'h':
case 'k':
case KEY_LEFT:
case KEY_UP:
case KEY_PPAGE:
if (i > 0) {
i--;
goto show;
}
goto again;
/* first */
case 'u':
case KEY_BEG:
i = 0;
goto show;
/* last */
case 'i':
case KEY_END:
i = argc - 1;
goto show;
default:
goto again;
}
/* unmap mem */
for (i = 0; argv[i] != NULL; i++)
munmap(p[i], 0x1000);
endwin(); /* restore terminal */
return (0);
}

13
showoff/00-intro.txt Normal file
View File

@ -0,0 +1,13 @@
.----------------------------------------------------------------.
| How to transform your presentation into pure art with catpoint |
'----------------------------------------------------------------'
Lazaros Koromilas <lostd@2f30.org>
http://www.2f30.org/~lostd

18
showoff/01-files.txt Normal file
View File

@ -0,0 +1,18 @@
Create the slides
=================
o Create a text file for every slide
00-intro.txt
01-files.txt
02-config.txt
03-run.txt
04-graph.txt
99-end.txt
o You can use banner or figlet to generate text art
o You can use gnuplot to produce graphs using
set term dumb

12
showoff/02-config.txt Normal file
View File

@ -0,0 +1,12 @@
Configure the environment
=========================
o You can alter your xterm defaults by adding the
following lines to your ~/.Xdefaults:
XTerm*background: white
XTerm*foreground: black
XTerm*faceName: xft:Monospace:size=16
o Open an xterm and maximize its window

9
showoff/03-run.txt Normal file
View File

@ -0,0 +1,9 @@
Run the presentation
====================
o Go to the directory where the files live
o Run catpoint with the list of files as arguments
$ catpoint *.txt

22
showoff/04-graph.txt Normal file
View File

@ -0,0 +1,22 @@
Show graphs
===========
+---------+---------+---------+---------+---------+---------+---------+
| Rate +----+ |
| |
20 ++ +-+ ++
| +-+ | | +-+ |
| | | | | | | |
15 ++ +-+ | | | | | | ++
| | | | | | | | | |
| | | | | | | | | |
10 ++ +-+ | | | | | | | | ++
| | | | | | | | | | | |
| | | | | | | | | | | |
5 ++ +-+ | | | | | | | | | | ++
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
0 ++--------+---------+---------+---------+---------+---------+--------++
60 128 256 512 1024 1514
Packet size (bytes)

8
showoff/05-export.txt Normal file
View File

@ -0,0 +1,8 @@
Exporting
=========
o Easily create a basic Black on White PDF export like that:
$ enscript *.txt -Brf "Courier16" -p - > slides.ps
$ ps2pdf slides.ps

12
showoff/99-end.txt Normal file
View File

@ -0,0 +1,12 @@
EOF
===
_____ _ _ _
|_ _| |__ __ _ _ __ | | _____| |
| | | '_ \ / _` | '_ \| |/ / __| |
| | | | | | (_| | | | | <\__ \_|
|_| |_| |_|\__,_|_| |_|_|\_\___(_)