home *** CD-ROM | disk | FTP | other *** search
- /*
- puprompt.c 7/25/86
-
- % pop_Prompt
-
- Popup prompt function.
-
- C-scape 3.2
- Copyright (c) 1986, 1987, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 9/16/88 jmd updated for 3.0
- 11/05/88 jmd removed menu_Close
-
- 4/22/89 jmd changed border to bord
-
- 10/16/89 jdc fixed "Press ESC" centering calculation
- 12/18/89 jmd changed "Press ESC" to "Ok", added mouse support
- 3/28/90 jmd ansi-fied
- 10/12/90 jdc moved placement of SetWrapWidth
- 12/14/90 jdc polished auto-sizing
- */
-
- #include <stdio.h>
-
- #include "cscape.h"
- #include "scancode.h"
- #include "teddecl.h"
- #include "popdecl.h"
-
- void pop_Prompt(char *msg, int row, int col, int height, int width, byte color, bd_fptr bord)
- /*
- Puts up a message in a box.
- Waits for user response.
- */
- {
- menu_type menu;
- sed_type sed;
- int wid, w;
- unsigned int len;
-
- if ((menu = menu_Open()) == NULL) {
- return;
- }
- for (len = 0; msg[len] != '\0'; len++) ;
- if (!menu_SetTB(menu, msg, len)) {
- menu_Destroy(menu);
- return;
- }
-
- if ((sed = sed_Open(menu)) == NULL) {
- menu_Destroy(menu);
- return;
- }
-
- sed_SetColors(sed, color, color, invert_char(color) & 0x7f);
- sed_SetMouse(sed, sedmou_GreedyTrack);
- sed_SetBorder(sed, bord);
- sed_SetBorderFeature(sed, BD_MOVE);
- 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, NULL);
-
- /* add the "ok" button */
- wid = (sed_GetWidth(sed) - 4)/2;
- if (wid < 0) wid = 0;
- if (!menu_Printf(menu, "@p[%d,%d]@f[ Ok ]", menu_GetHeight(menu) + 1,
- wid, NULL, &menu_funcs)) {
-
- sed_Close(sed);
- return;
- }
- pop_SetParms(sed, row, col, height, width, NULL);
-
- sed_SetCursorType(sed, CURSOR_NONE);
- sed_Repaint(sed);
-
- /* wait for user response */
- sed_Go(sed);
-
- sed_Close(sed);
- }
-