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

Nathanael Nerode neroden-guest at costa.debian.org
Tue Sep 6 11:59:04 UTC 2005


Author: neroden-guest
Date: 2005-09-06 11:59:03 +0000 (Tue, 06 Sep 2005)
New Revision: 173

Modified:
   pinfo/branches/cxx/src/initializelinks.cxx
   pinfo/branches/cxx/src/initializelinks.h
   pinfo/branches/cxx/src/mainfunction.cxx
   pinfo/branches/cxx/src/video.cxx
   pinfo/branches/cxx/src/video.h
Log:
Stringify video.cxx, with incidental constification.


Modified: pinfo/branches/cxx/src/initializelinks.cxx
===================================================================
--- pinfo/branches/cxx/src/initializelinks.cxx	2005-09-06 11:37:19 UTC (rev 172)
+++ pinfo/branches/cxx/src/initializelinks.cxx	2005-09-06 11:59:03 UTC (rev 173)
@@ -66,7 +66,7 @@
  * Bugs: this doesn't actually work.  FIXME.
  */
 int
-calculate_len(char *start, char *end)
+calculate_len(const char *start, const char *end)
 {
 	int len = 0;
 	while (start < end)

Modified: pinfo/branches/cxx/src/initializelinks.h
===================================================================
--- pinfo/branches/cxx/src/initializelinks.h	2005-09-06 11:37:19 UTC (rev 172)
+++ pinfo/branches/cxx/src/initializelinks.h	2005-09-06 11:59:03 UTC (rev 173)
@@ -38,5 +38,5 @@
  * calculate length of visible part of string ('\t' included) between start and
  * end. Returns length.
  */
-int calculate_len (char *start, char *end);
+int calculate_len (const char *start, const char *end);
 #endif

Modified: pinfo/branches/cxx/src/mainfunction.cxx
===================================================================
--- pinfo/branches/cxx/src/mainfunction.cxx	2005-09-06 11:37:19 UTC (rev 172)
+++ pinfo/branches/cxx/src/mainfunction.cxx	2005-09-06 11:59:03 UTC (rev 173)
@@ -180,9 +180,15 @@
 		{
 			if (statusline == FREE) {
 				/* Quick conversion to vector.  Temporary, FIXME. */
-				vector<char *> my_message;
+				vector<string> my_message;
 				for (typeof(my_message.size()) x = 0; x < Lines; x++) {
-					my_message.push_back(Message[x]);
+					if ((*message)[x] == NULL) {
+						my_message.push_back("");
+						/* Yaah, FIXME.  index 0 is funky. */
+					} else {
+						string foo = (*message)[x];
+						my_message.push_back(foo);
+					}
 				}
 				showscreen(my_message, pos, cursor, infocolumn);
 			}

Modified: pinfo/branches/cxx/src/video.cxx
===================================================================
--- pinfo/branches/cxx/src/video.cxx	2005-09-06 11:37:19 UTC (rev 172)
+++ pinfo/branches/cxx/src/video.cxx	2005-09-06 11:59:03 UTC (rev 173)
@@ -27,7 +27,7 @@
 #include <vector>
 using std::vector;
 
-void info_add_highlights(int pos, int cursor, int column, vector <char *> message);
+void info_add_highlights(int pos, int cursor, int column, const vector <string> message);
 
 /*
  * Replace first occurence of substring in string.
@@ -70,7 +70,7 @@
 }
 
 void
-showscreen(vector <char *> message, long pos, long cursor, int column)
+showscreen(const vector <string> message, long pos, long cursor, int column)
 {
 	long i;
 #ifdef getmaxyx
@@ -82,12 +82,12 @@
 	attrset(normal);
 	for (i = pos;(i < message.size()) &&(i < pos + maxy - 2); i++)
 	{
-		if (!message[i]) continue;
+		if (message[i] == "") continue;
 
-		int tmp = strlen(message[i]) - 1;
-		message[i][tmp] = 0;
-		if (tmp>column)
-			mvaddstr(i + 1 - pos, 0, message[i]+column);
+		/* Chop off trailing newline */
+		string tmpstr = message[i].substr(0, message[i].length() - 1);
+		if (tmpstr.length()>column)
+			mvaddstr(i + 1 - pos, 0, tmpstr.substr(column).c_str());
 		else
 			move(i + 1 - pos,0);
 #ifdef HAVE_BKGDSET
@@ -95,7 +95,6 @@
 #else
 		myclrtoeol();
 #endif
-		message[i][tmp] = '\n';
 	}
 	clrtobot();
 #ifdef HAVE_BKGDSET
@@ -144,7 +143,7 @@
 }
 
 void
-info_add_highlights(int pos, int cursor, int column, vector <char *> message)
+info_add_highlights(int pos, int cursor, int column, const vector <string> message)
 {
 	for (typeof(hyperobjects.size()) i = 0; i < hyperobjects.size(); i++) {
 		if ((hyperobjects[i].line < pos) ||
@@ -224,18 +223,17 @@
 			 */
 			for (int j = 0; j < maxregexp; j++)
 			{
-				char *str = message[i];
+				const char * message_i = message[i].c_str();
+				const char *str = message_i;
 				while (!regexec(&h_regexp[j], str, 1, pmatch, 0))
 				{
 					int n = pmatch[0].rm_eo - pmatch[0].rm_so;
 					int y = i - pos + 1;
-					int x = calculate_len(message[i], pmatch[0].rm_so + str);
-					int txtoffset = (str - message[i]) + pmatch[0].rm_so;
-					string tmpstr = message[i];
-					tmpstr.resize(x+n);
-					string tmpstr2 = tmpstr.substr(txtoffset);
+					int x = calculate_len(message_i, pmatch[0].rm_so + str);
+					int txtoffset = (str - message_i) + pmatch[0].rm_so;
+					string tmpstr = message[i].substr(txtoffset, x + n);
 					attrset(searchhighlight);
-					mvaddstr(y, x, tmpstr2.c_str());
+					mvaddstr(y, x, tmpstr.c_str());
 					attrset(normal);
 					str = str + pmatch[0].rm_eo;
 				}

Modified: pinfo/branches/cxx/src/video.h
===================================================================
--- pinfo/branches/cxx/src/video.h	2005-09-06 11:37:19 UTC (rev 172)
+++ pinfo/branches/cxx/src/video.h	2005-09-06 11:59:03 UTC (rev 173)
@@ -25,7 +25,7 @@
 #define __VIDEO_H
 #include <string>
 /* paints the screen while viewing info file */
-void showscreen (std::vector<char *> message, long pos,
+void showscreen (const std::vector<std::string> message, long pos,
 		long cursor, int column);
 /* prints unselected menu option */
 void mvaddstr_menu (int y, int x, char *line, int linenumber);




More information about the Pinfo-devel mailing list