2 * Copyright (c) 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid
[] = "@(#)tk_funcs.c 8.11 (Berkeley) 9/23/96";
16 #include <sys/types.h>
17 #include <sys/queue.h>
20 #include <bitstring.h>
29 #include "../common/common.h"
35 * Add len bytes from the string at the cursor, advancing the cursor.
37 * PUBLIC: int tk_addstr __P((SCR *, const char *, size_t));
40 tk_addstr(sp
, str
, len
)
53 (void)Tcl_Eval(tkp
->interp
, "tk_standout");
55 (void)snprintf(buf
, sizeof(buf
), "%d ", (int)len
);
56 if ((Tcl_VarEval(tkp
->interp
,
57 "tk_addstr ", buf
, "{", str
, "}", NULL
) != TCL_OK
))
61 (void)Tcl_Eval(tkp
->interp
, "tk_standend");
67 * Toggle a screen attribute on/off.
69 * PUBLIC: int tk_attr __P((SCR *, scr_attr_t, int));
72 tk_attr(sp
, attribute
, on
)
81 case SA_ALTERNATE
: /* No alternate screen. */
85 (void)Tcl_Eval(tkp
->interp
, "tk_standout");
87 (void)Tcl_Eval(tkp
->interp
, "tk_standend");
97 * Return the baud rate.
99 * PUBLIC: int tk_baud __P((SCR *, u_long *));
112 * Ring the bell/flash the screen.
114 * PUBLIC: int tk_bell __P((SCR *));
123 return (Tcl_Eval(tkp
->interp
, "tk_flash") != TCL_OK
);
128 * Clear from the current cursor to the end of the line.
130 * PUBLIC: int tk_clrtoeol __P((SCR *));
139 return (Tcl_Eval(tkp
->interp
, "tk_clrtoeol") != TCL_OK
);
144 * Return the current cursor position.
146 * PUBLIC: int tk_cursor __P((SCR *, size_t *, size_t *));
149 tk_cursor(sp
, yp
, xp
)
156 *yp
= (tkp
->tk_cursor_row
- 1) - sp
->woff
;
157 *xp
= tkp
->tk_cursor_col
;
163 * Delete the current line, scrolling all lines below it.
165 * PUBLIC: int tk_deleteln __P((SCR *));
174 return (Tcl_Eval(tkp
->interp
, "tk_deleteln") != TCL_OK
);
179 * Adjust the screen for ex.
181 * PUBLIC: int tk_ex_adjust __P((SCR *, exadj_t));
184 tk_ex_adjust(sp
, action
)
194 * Push down the current line, discarding the bottom line.
196 * PUBLIC: int tk_insertln __P((SCR *));
205 return (Tcl_Eval(tkp
->interp
, "tk_insertln") != TCL_OK
);
210 * Return the value for a special key.
212 * PUBLIC: int tk_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
215 tk_keyval(sp
, val
, chp
, dnep
)
224 * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
225 * VWERASE is a 4BSD extension.
230 *dnep
= (*chp
= tkp
->orig
.c_cc
[VEOF
]) == _POSIX_VDISABLE
;
233 *dnep
= (*chp
= tkp
->orig
.c_cc
[VERASE
]) == _POSIX_VDISABLE
;
236 *dnep
= (*chp
= tkp
->orig
.c_cc
[VKILL
]) == _POSIX_VDISABLE
;
240 *dnep
= (*chp
= tkp
->orig
.c_cc
[VWERASE
]) == _POSIX_VDISABLE
;
254 * PUBLIC: int tk_move __P((SCR *, size_t, size_t));
257 tk_move(sp
, lno
, cno
)
264 (void)snprintf(buf
, sizeof(buf
), "%d %d", RLNO(sp
, lno
), cno
);
267 return (Tcl_VarEval(tkp
->interp
, "tk_move ", buf
, NULL
) != TCL_OK
);
272 * Refresh the screen.
274 * PUBLIC: int tk_refresh __P((SCR *, int));
277 tk_refresh(sp
, repaint
)
284 * If repaint is set, the editor is telling us that we don't know
285 * what's on the screen, so we have to repaint from scratch.
288 * I have no idea how to do this in Tk. My guess is that we have
289 * to delete all of the text and call the editor with an E_REPAINT
296 return (Tcl_Eval(tkp
->interp
, "update idletasks") != TCL_OK
);
303 * PUBLIC: int tk_rename __P((SCR *));
312 return (Tcl_VarEval(tkp
->interp
,
313 "tk_rename ", sp
->frp
->name
, NULL
) != TCL_OK
);
320 * PUBLIC: int tk_suspend __P((SCR *, int *));
323 tk_suspend(sp
, allowedp
)
333 * Print out the Tk/Tcl usage messages.
335 * PUBLIC: void tk_usage __P((void));
341 usage: tkvi [-eFlRrSv] [-c command] [-bg color] [-fg color]\n\
342 [-geometry widthxheight+x+y] [-i script] [-t tag] [-w size]\n\
344 (void)fprintf(stderr
, "%s", USAGE
);