1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
/* Text in a 'window'
* Copyright (C) 1998 J.A. Bezemer
*
* Licensed under the terms of the GNU General Public License.
* ABSOLUTELY NO WARRANTY.
* See the file `COPYING' in this directory.
*/
#include "textwindow.h"
#include <stdlib.h>
#include <string.h>
#ifndef OLD_CURSES
#include <ncurses.h>
#else
#include <curses.h>
#endif
void
display_textwin (char *text, int y, int x, int h, int w)
/* (y,x): upper left position of 'text block'
h = heigth, w = width of block */
{
int current_y;
char mytext[DISPLAYMENU_MAXTEXTLEN];
char mytext2[DISPLAYMENU_MAXTEXTLEN];
char helptext[DISPLAYMENU_MAXTEXTLEN];
char *lastspace;
int i;
current_y = y;
strncpy (mytext, text, DISPLAYMENU_MAXTEXTLEN);
do
{
strncpy (mytext2, mytext, w + 1);
mytext2[w + 1] = '\0';
if (strlen (mytext2) > w)
{
lastspace = strrchr (mytext2, ' ');
if (lastspace != NULL)
{
mytext2[lastspace - mytext2] = '\0';
strcpy (helptext, mytext + (lastspace - mytext2 + 1));
strcpy (mytext, helptext);
}
else
/* no space... */
{
mytext2[w] = '\0';
strcpy (helptext, mytext + w);
strcpy (mytext, helptext);
}
}
else /* strlen(mytext2) <= w */
mytext[0] = '\0';
mvaddstr (current_y, x, mytext2);
for (i = strlen (mytext2) + 1; i <= w; i++)
addch (' ');
current_y++;
}
while (current_y < y + h /*&& strlen(mytext) > 0 */ );
}
|