home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
PUVIEW.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-14
|
3KB
|
165 lines
/*
puview.c
% pop_View
Popup file viewing routine.
C-scape 3.2
Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
8/06/87 jmd added missing help function
6/02/88 jdc converted to new textbuf stuff
8/23/88 jmd fixed SetTB, removed attributes
9/16/88 jmd updated for 3.0
11/05/88 jmd removed menu_Close
4/22/89 jmd changed border to bord
6/12/89 jmd removed kb_Clear
9/07/89 jmd fixed default size trouble
3/28/90 jmd ansi-fied
10/19/90 mla added mouse support
10/21/90 bkd fixed declaration of puview_fkey().
10/31/90 ted changed NULL ff struct entries to FNULL.
12/14/90 jdc polished auto-sizing
*/
#include <stdio.h>
#include <string.h>
#include "cscape.h"
#include "scancode.h"
#include "teddecl.h"
#include "popdecl.h"
#include "helpdecl.h"
OSTATIC void puview_fkey(sed_type sed);
OSTATIC field_funcs_struct puview_funcs = {
FNULL,
FNULL,
puview_fkey,
FNULL,
FNULL,
0
};
void pop_View(char *title, char *text, int row, int col, int height, int width, byte color, int label, bd_fptr bord)
/*
Places text in a window.
Allows the text to be scrolled around.
Exits when ESC is pressed.
standard use of row, col etc...
*/
{
sed_type sed;
menu_type menu;
unsigned int len;
int w;
if ((menu = menu_Open()) == NULL) {
return;
}
if (!menu_Printf(menu, "@f[]", NULL, &puview_funcs)) {
menu_Destroy(menu);
return;
}
for (len = 0; text[len] != '\0'; len++) ;
if (!menu_SetTB(menu, text, len)) {
menu_Destroy(menu);
return;
}
if ((sed = sed_Open(menu)) == NULL) {
menu_Destroy(menu);
return;
}
sed_SetColors(sed, color, color, color);
sed_SetBorder(sed, bord);
sed_SetMouse(sed, sedmou_GreedyTrack);
sed_SetLabel(sed, label);
sed_SetCursorType(sed, CURSOR_NONE); /* turn off the cursor */
if (width > 0) {
w = width;
}
else if (popparms.width > 0) {
w = popparms.width;
}
else {
w = disp_GetWidth() - (bord_GetWidth(sed) - sed_GetWidth(sed));
if (col > 0) {
w -= col;
}
}
ted_SetWrapWidth(sed, w);
menu_SetDirty(menu, TRUE);
menu_RecalcSize(menu);
pop_SetParms(sed, row, col, height, width, title);
/* put up the sed */
sed_Repaint(sed);
sed_BorderPrompt(sed, ocountry.pressesc);
sed_Go(sed);
sed_Close(sed);
}
static void puview_fkey(sed_type sed)
/*
processes input events for pop_View
*/
{
switch(kb_Read()) {
case FN1:
help_Show(sed_GetLabel(sed), 0);
break;
case INS:
break;
case HOME:
sed_ScrollUp(sed, sed_GetYoffset(sed));
break;
case END:
sed_ScrollDown(sed, sed_GetMenuHeight(sed));
break;
case UP:
sed_ScrollUp(sed, 1);
break;
case DOWN:
sed_ScrollDown(sed, 1);
break;
case LEFT:
sed_ScrollLeft(sed, 5);
break;
case RIGHT:
sed_ScrollRight(sed, 5);
break;
case CTRL_LEFT:
sed_ScrollLeft(sed, sed_GetXoffset(sed));
break;
case CTRL_RIGHT:
sed_ScrollRight(sed, sed_GetMenuWidth(sed));
break;
case PGUP:
sed_PageUp(sed);
break;
case PGDN:
sed_PageDown(sed);
break;
case MOU_THERE: /* the mouse was clicked outside this window */
case ESC:
sed_ToggleExit(sed);
break;
default:
break;
}
}