home *** CD-ROM | disk | FTP | other *** search
- /*
- puedit.c 9/16/88
-
- % pop_Edit
-
- Popup editor.
-
- C-scape 3.2
- Copyright (c) 1988 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 11/05/88 jmd removed menu_Close
- 11/19/88 jmd now uses ted_funcs
-
- 4/22/89 jmd changed border to bord
- 9/07/89 jmd fixed default size trouble
- 3/28/90 jmd ansi-fied
- 10/19/90 mla added mouse support
- 12/03/90 jdc added data pointers to ted_funcs field (for copy buffer)
- 12/14/90 jdc polished auto-sizing
- */
-
- #include <stdio.h>
-
- #include "cscape.h"
- #include "strdecl.h" /* for invert_char() */
- #include "teddecl.h"
- #include "popdecl.h"
-
- void pop_Edit(char *title, char *text, unsigned tlen, int row, int col, int height, int width, byte color, int label, bd_fptr bord)
- /*
- Places text in a window.
- The text can be edited.
- Exits when ESC is pressed.
- standard use of row, col etc...
- */
- {
- sed_type sed;
- menu_type menu;
- int w;
- unsigned int len;
-
- if ((menu = menu_Open()) == NULL) {
- return;
- }
-
- if (!menu_Printf(menu, "@fD2[]", text, &ted_funcs)) {
- menu_Destroy(menu);
- return;
- }
- if ((width < 0 && popparms.width < 0) || (height < 0 && popparms.height < 0)) {
- /* must load text to auto-size */
- for (len = 0; text[len] != '\0'; len++) ;
- if (!menu_SetTB(menu, text, len)) {
- menu_Destroy(menu);
- return;
- }
- }
-
- menu_Flush(menu);
- 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_SetLabel(sed, label);
- sed_SetBorder(sed, bord);
-
- 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 - 1);
- menu_SetDirty(menu, TRUE);
- menu_RecalcSize(menu);
-
- pop_SetParms(sed, row, col, height, w, title);
-
- /* clear out pre-loaded text */
- sed_ClearTB(sed);
-
- /* set ted parameters */
- ted_SetInsert(sed, TED_INSERT);
- ted_SetMoveMethod(sed, ted_Follow);
- ted_SetMaxSize(sed, (long) tlen);
-
- /* put up the sed */
- sed_Repaint(sed);
- sed_Go(sed);
-
- /* close the sed */
- sed_Close(sed);
- }
-