[Pinfo-devel] r256 - pinfo/branches/cxx/src

Nathanael Nerode neroden-guest at costa.debian.org
Mon Sep 26 06:18:41 UTC 2005


Author: neroden-guest
Date: 2005-09-26 06:18:38 +0000 (Mon, 26 Sep 2005)
New Revision: 256

Modified:
   pinfo/branches/cxx/src/Makefile.am
   pinfo/branches/cxx/src/common_includes.h
   pinfo/branches/cxx/src/filehandling_functions.cxx
   pinfo/branches/cxx/src/initializelinks.cxx
   pinfo/branches/cxx/src/mainfunction.cxx
   pinfo/branches/cxx/src/manual.cxx
   pinfo/branches/cxx/src/parse_config.cxx
   pinfo/branches/cxx/src/pinfo.cxx
   pinfo/branches/cxx/src/signal_handler.cxx
   pinfo/branches/cxx/src/utils.cxx
   pinfo/branches/cxx/src/utils.h
   pinfo/branches/cxx/src/video.cxx
Log:
Break half of utils.[h,c] out to curse_utils.[h,c] -- the part
which is mostly about dealing with ncurses.


Modified: pinfo/branches/cxx/src/Makefile.am
===================================================================
--- pinfo/branches/cxx/src/Makefile.am	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/Makefile.am	2005-09-26 06:18:38 UTC (rev 256)
@@ -14,8 +14,6 @@
 		parse_config.cxx \
 		regexp_search.cxx \
 		signal_handler.cxx \
-		utils.cxx \
-		video.cxx \
 		colors.h \
 		common_includes.h \
 		datatypes.h \
@@ -26,8 +24,12 @@
 		parse_config.h \
 		regexp_search.h \
 		signal_handler.h \
+		curse_utils.h \
+		curse_utils.cxx \
 		utils.h \
+		utils.cxx \
 		video.h \
+		video.cxx \
 		initializelinks.cxx \
 		initializelinks.h \
 		printinfo.cxx \

Modified: pinfo/branches/cxx/src/common_includes.h
===================================================================
--- pinfo/branches/cxx/src/common_includes.h	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/common_includes.h	2005-09-26 06:18:38 UTC (rev 256)
@@ -59,7 +59,6 @@
 #include "datatypes.h"
 #include "filehandling_functions.h"
 #include "mainfunction.h"
-#include "utils.h"
 
 /* I hear voices, that it is needed by RH5.2 ;) */
 #define _REGEX_RE_COMP

Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -29,6 +29,7 @@
 #include <algorithm> // for std::sort
 
 #include "colors.h"
+#include "curse_utils.h"
 #include "tmpfiles.h"
 #include "utils.h"
 

Modified: pinfo/branches/cxx/src/initializelinks.cxx
===================================================================
--- pinfo/branches/cxx/src/initializelinks.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/initializelinks.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -26,10 +26,11 @@
 using std::vector;
 #include <algorithm> // for std::sort
 
+#include "utils.h"
+
 #define MENU_DOT 0
 #define NOTE_DOT 1
 
-
 bool
 compare_hyperlink(HyperObject a, HyperObject b)
 {

Modified: pinfo/branches/cxx/src/mainfunction.cxx
===================================================================
--- pinfo/branches/cxx/src/mainfunction.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/mainfunction.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -31,10 +31,12 @@
 #include <ctype.h>
 
 #include "colors.h"
+#include "curse_utils.h"
 #include "initializelinks.h"
 #include "keyboard.h"
 #include "printinfo.h"
 #include "regexp_search.h"
+#include "utils.h"
 #include "video.h"
 
 /* File-scope globals.  FIXME */

Modified: pinfo/branches/cxx/src/manual.cxx
===================================================================
--- pinfo/branches/cxx/src/manual.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/manual.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -31,11 +31,13 @@
 #include <sys/stat.h>
 
 #include "colors.h"
+#include "curse_utils.h"
 #include "initializelinks.h"
 #include "keyboard.h"
 #include "manual.h"
 #include "regexp_search.h"
 #include "tmpfiles.h"
+#include "utils.h"
 
 #define HTTPSECTION 100
 #define FTPSECTION 101

Modified: pinfo/branches/cxx/src/parse_config.cxx
===================================================================
--- pinfo/branches/cxx/src/parse_config.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/parse_config.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -33,6 +33,7 @@
 #include "keyboard.h"
 #include "parse_config.h"
 #include "regexp_search.h"
+#include "utils.h"
 
 #define COLOR_DEFAULT -1	/* mutt uses this was for transparency */
 

Modified: pinfo/branches/cxx/src/pinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/pinfo.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/pinfo.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -32,6 +32,7 @@
 #endif
 
 #include "colors.h"
+#include "curse_utils.h"
 #include "manual.h"
 #include "parse_config.h"
 #include "regexp_search.h"

Modified: pinfo/branches/cxx/src/signal_handler.cxx
===================================================================
--- pinfo/branches/cxx/src/signal_handler.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/signal_handler.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -27,6 +27,7 @@
 #include <termios.h>
 #include <sys/ioctl.h>
 
+#include "curse_utils.h"
 #include "keyboard.h"
 
 void

Modified: pinfo/branches/cxx/src/utils.cxx
===================================================================
--- pinfo/branches/cxx/src/utils.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/utils.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -29,51 +29,11 @@
 #include <utility> // for std::pair
 #include <algorithm> // for std::equal_range
 
-#include <clocale> // for setlocale
+#include "datatypes.h" // for TagTable
 
-#include <ctype.h>
-
-#include "colors.h"
-#include "keyboard.h"
-#include "tmpfiles.h"
-
 string safe_user = "nobody";
 string safe_group = "nogroup";
 
-#ifndef HAVE_CURS_SET
-void
-curs_set(int a)
-{
-}
-#endif
-
-/* Readline */
-#include <readline/readline.h>
-#include <readline/history.h>
-#include <term.h>
-
-int curses_open = 0;
-
-int shell_cursor = 1;
-
-void
-initlocale()
-{
-#ifdef HAVE_SETLOCALE
-	std::setlocale(LC_ALL, "");
-#endif
-	bindtextdomain(PACKAGE, LOCALEDIR);
-	textdomain(PACKAGE);
-}
-
-void
-mymvhline(int y, int x, char ch, int len)
-{
-	int i;
-	for (i = 0; i < len; i++)
-		mvaddch(y, x + i, ch);
-}
-
 /*
  * Check filename for dangerous characters and bail out if
  * we find any.
@@ -96,81 +56,10 @@
 	}
 }
 
-/* custom function that readline will use to display text */
-void
-my_rl_display()
-{
-	/* go to the bottom line, empty it, and print the prompt and buffer */
-	attrset(bottomline);
-	mymvhline(maxy - 1, 0, ' ', maxx);
-	move(maxy-1,0);
-	printw("%s%s", rl_prompt, rl_line_buffer);
-	refresh();
-}
-
-string
-getstring(const char *prompt)
-{
-	char *buf;
-
-	curs_set(1);
-	move(maxy - 1, 0);
-	refresh();
-
-	rl_readline_name = PACKAGE;
-	
-	/* set display function for readline to my_rl_display and call readline */
-	rl_redisplay_function = my_rl_display;
-	buf = readline(prompt);
-	if (buf && *buf) 
-		add_history(buf);
-	
-	curs_set(0);
-
-	string my_string;
-	if (buf == NULL) {
-		my_string = "";
-	} else {
-		my_string = buf;
-		free(buf);
-	}
-	return my_string;
-}
-
-void
-init_curses()
-{
-	initscr();
-	noecho();
-	cbreak();
-	keypad(stdscr, TRUE);
-	/*  meta(stdscr, TRUE); */
-	initcolors();
-	shell_cursor = curs_set(0);
-#ifdef NCURSES_MOUSE_VERSION
-	mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED, NULL);
-/* NCURSES_MOUSE_VERSION */
-#endif
-	curses_open = 1;
-}
-
-
-void
-closeprogram()
-{
-	if (curses_open)
-		myendwin();
-	if (ClearScreenAtExit)
-		system("clear");
-	else
-		printf("\n");
-	rmtmpfiles();
-}
-
 /*
  * Compares two strings, ignoring whitespaces(tabs, spaces)
  */
-int
+static int
 compare_tag_table_string(const char *base, const char *compared)
 {
 	int i = 0;
@@ -218,7 +107,7 @@
 }
 
 int
-gettagtablepos(string node)
+gettagtablepos(const string& node)
 {
   TagTable dummy;
 	dummy.nodename = node;
@@ -237,106 +126,6 @@
 	}
 }
 
-int
-pinfo_getch()
-{
-	int key = getch();
-	/* following key will be alt's value */
-	if (key == META_KEY)
-	{
-		key = getch();
-		key |= 0x200;
-	}
-	return key;
-}
-
-void
-waitforgetch()
-{
-	fd_set rdfs;
-	FD_ZERO(&rdfs);
-	FD_SET(0, &rdfs);
-	select(1, &rdfs, NULL, NULL, NULL);
-}
-
-int
-yesno(const char *prompt, int def)
-{
-	const char *yes = _("yes");
-	const char *no = _("no");
-	int key;
-
-	attrset(bottomline);
-	mymvhline(maxy - 1, 0, ' ', maxx);
-	move(maxy - 1, 0);
-	/* if default answer is yes */
-	if (def)
-		printw("%s([%c]/%c)", prompt, *yes, *no);
-	else
-		printw("%s([%c]/%c)", prompt, *no, *yes);
-	nodelay(stdscr, FALSE);
-	while (1)
-	{
-		key = getch();
-		if (key == ERR)
-			return -1;
-		if (is_enter_key(key))
-			break;
-		else
-		{
-			if (tolower(key) == tolower(*yes))
-			{
-				def = 1;
-				break;
-			}
-			else
-			{
-				if (tolower(key) == tolower(*no))
-				{
-					def = 0;
-					break;
-				}
-				else
-					beep();
-			}
-		}
-	}
-
-	nodelay(stdscr, TRUE);
-	if (def)
-		addstr(yes);
-	else
-		addstr(no);
-	attrset(normal);
-	return def;
-}
-
-void
-myclrtoeol()
-{
-	int x, y, i;
-	getyx(stdscr, y, x);
-	for (i = x; i < maxx; i++)
-		mvaddch(y, i, ' ');
-}
-
-void
-myendwin()
-{
-	curs_set(shell_cursor);
-	endwin();
-}
-
-void
-handlewinch()
-{
-	myendwin();
-	init_curses();
-	doupdate();
-	getmaxyx(stdscr, maxy, maxx);
-	ungetch(keys.refresh_1);
-}
-
 /*
  * Create a vector of strings.  If the strings are concatenated together
  * with separator in between them, the original string will be recovered.

Modified: pinfo/branches/cxx/src/utils.h
===================================================================
--- pinfo/branches/cxx/src/utils.h	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/utils.h	2005-09-26 06:18:38 UTC (rev 256)
@@ -29,48 +29,15 @@
 extern std::string safe_user;
 extern std::string safe_group;
 
-#ifndef HAVE_CURS_SET
-void curs_set (int a);
-#endif
-
-/* user defined getch, capable of handling ALT keybindings */
-int pinfo_getch ();
-/* initializes GNU locales */
-void initlocale ();
 /* bail out if file name causes security problems */
 void checkfilename (const std::string filename);
-/* closes the program, and removes temporary files */
-void closeprogram ();
-/* initializes curses interface */
-void init_curses ();
-/* an interface to gnu readline */
-std::string getstring (const char *prompt);
-/* for some reasons mvhline does not work quite properly... */
-void mymvhline (int y, int x, char ch, int len);
-/* this one supports color back/foreground */
-void myclrtoeol ();
-/* takes care of the cursor, which is turned off */
-void myendwin ();
 
 /* strcmp, which is insensitive to whitespaces */
-int compare_tag_table_string (const char *base, const char *compared);
 bool compare_tags (TagTable a, TagTable b);
 
 /* get offset of "node" in tag_table variable */
-int gettagtablepos (std::string node);
+int gettagtablepos (const std::string & node);
 
-/* handle localized `(y/n)' dialog box.  */
-int yesno (const char *prompt, int def);
-
-/* Block until something's on STDIN */
-void waitforgetch ();
-
-/* Handle SIGWINCH */
-void handlewinch ();
-
-/* is curses screen open? */
-extern int curses_open;
-
 /* Explode a string into a vector */
 std::vector<std::string>
 string_explode(const std::string & to_explode,

Modified: pinfo/branches/cxx/src/video.cxx
===================================================================
--- pinfo/branches/cxx/src/video.cxx	2005-09-26 05:21:54 UTC (rev 255)
+++ pinfo/branches/cxx/src/video.cxx	2005-09-26 06:18:38 UTC (rev 256)
@@ -28,6 +28,7 @@
 using std::vector;
 
 #include "colors.h"
+#include "curse_utils.h"
 #include "initializelinks.h" // for bletchulous calculate_len
 #include "regexp_search.h"
 




More information about the Pinfo-devel mailing list