chared.h revision 92917
193139Sru/*-
293139Sru * Copyright (c) 1992, 1993
393139Sru *	The Regents of the University of California.  All rights reserved.
493139Sru *
593139Sru * This code is derived from software contributed to Berkeley by
693139Sru * Christos Zoulas of Cornell University.
793139Sru *
893139Sru * Redistribution and use in source and binary forms, with or without
993139Sru * modification, are permitted provided that the following conditions
1093139Sru * are met:
1193139Sru * 1. Redistributions of source code must retain the above copyright
1293139Sru *    notice, this list of conditions and the following disclaimer.
1393139Sru * 2. Redistributions in binary form must reproduce the above copyright
1493139Sru *    notice, this list of conditions and the following disclaimer in the
1593139Sru *    documentation and/or other materials provided with the distribution.
1693139Sru * 3. All advertising materials mentioning features or use of this software
1793139Sru *    must display the following acknowledgement:
1893139Sru *	This product includes software developed by the University of
1993139Sru *	California, Berkeley and its contributors.
2093139Sru * 4. Neither the name of the University nor the names of its contributors
2193139Sru *    may be used to endorse or promote products derived from this software
2293139Sru *    without specific prior written permission.
2393139Sru *
2493139Sru * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2593139Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2693139Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2793139Sru * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2893139Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2993139Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3093139Sru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3193139Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3293139Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3393139Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3493139Sru * SUCH DAMAGE.
3593139Sru *
3693139Sru *	@(#)chared.h	8.1 (Berkeley) 6/4/93
3793139Sru *	$NetBSD: chared.h,v 1.5 2000/09/04 22:06:29 lukem Exp $
3893139Sru * $FreeBSD: head/lib/libedit/chared.h 92917 2002-03-21 23:54:04Z obrien $
3993139Sru */
4093139Sru
4193139Sru/*
4293139Sru * el.chared.h: Character editor interface
4393139Sru */
4493139Sru#ifndef _h_el_chared
4593139Sru#define	_h_el_chared
4693139Sru
4793139Sru#include <ctype.h>
4893139Sru#include <string.h>
4993139Sru
5093139Sru#include "histedit.h"
5193139Sru
5293139Sru#define	EL_MAXMACRO	10
5393139Sru
5493139Sru/*
5593139Sru * This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
5693139Sru * like real vi: i.e. the transition from command<->insert modes moves
5793139Sru * the cursor.
5893139Sru *
5993139Sru * On the other hand we really don't want to move the cursor, because
6093139Sru * all the editing commands don't include the character under the cursor.
6193139Sru * Probably the best fix is to make all the editing commands aware of
6293139Sru * this fact.
6393139Sru */
6493139Sru#define	VI_MOVE
6593139Sru
6693139Sru
6793139Srutypedef struct c_macro_t {
6893139Sru	int	  level;
6993139Sru	char	**macro;
7093139Sru	char	 *nline;
7193139Sru} c_macro_t;
7293139Sru
7393139Sru/*
7493139Sru * Undo information for both vi and emacs
7593139Sru */
7693139Srutypedef struct c_undo_t {
7793139Sru	int	 action;
7893139Sru	size_t	 isize;
7993139Sru	size_t	 dsize;
8093139Sru	char	*ptr;
8193139Sru	char	*buf;
8293139Sru} c_undo_t;
8393139Sru
8493139Sru/*
8593139Sru * Current action information for vi
8693139Sru */
8793139Srutypedef struct c_vcmd_t {
8893139Sru	int	 action;
8993139Sru	char	*pos;
9093139Sru	char	*ins;
9193139Sru} c_vcmd_t;
9293139Sru
9393139Sru/*
9493139Sru * Kill buffer for emacs
9593139Sru */
9693139Srutypedef struct c_kill_t {
9793139Sru	char	*buf;
9893139Sru	char	*last;
9993139Sru	char	*mark;
10093139Sru} c_kill_t;
10193139Sru
10293139Sru/*
10393139Sru * Note that we use both data structures because the user can bind
10493139Sru * commands from both editors!
10593139Sru */
10693139Srutypedef struct el_chared_t {
10793139Sru	c_undo_t	c_undo;
10893139Sru	c_kill_t	c_kill;
10993139Sru	c_vcmd_t	c_vcmd;
11093139Sru	c_macro_t	c_macro;
11193139Sru} el_chared_t;
11293139Sru
11393139Sru
11493139Sru#define	STReof		"^D\b\b"
11593139Sru#define	STRQQ		"\"\""
11693139Sru
11793139Sru#define	isglob(a)	(strchr("*[]?", (a)) != NULL)
11893139Sru#define	isword(a)	(isprint(a))
11993139Sru
12093139Sru#define	NOP		0x00
12193139Sru#define	DELETE		0x01
12293139Sru#define	INSERT		0x02
12393139Sru#define	CHANGE		0x04
12493139Sru
12593139Sru#define	CHAR_FWD	0
12693139Sru#define	CHAR_BACK	1
12793139Sru
12893139Sru#define	MODE_INSERT	0
12993139Sru#define	MODE_REPLACE	1
13093139Sru#define	MODE_REPLACE_1	2
13193139Sru
13293139Sru#include "common.h"
13393139Sru#include "vi.h"
13493139Sru#include "emacs.h"
13593139Sru#include "search.h"
13693139Sru#include "fcns.h"
13793139Sru
13893139Sru
13993139Sruprotected int	 cv__isword(int);
14093139Sruprotected void	 cv_delfini(EditLine *);
14193139Sruprotected char	*cv__endword(char *, char *, int);
14293139Sruprotected int	 ce__isword(int);
14393139Sruprotected int	 c___isword(int);
14493139Sruprotected void	 cv_undo(EditLine *, int, size_t, char *);
14593139Sruprotected char	*cv_next_word(EditLine*, char *, char *, int, int (*)(int));
14693139Sruprotected char	*cv_prev_word(EditLine*, char *, char *, int, int (*)(int));
14793139Sruprotected char	*c__next_word(char *, char *, int, int (*)(int));
14893139Sruprotected char	*c__prev_word(char *, char *, int, int (*)(int));
14993139Sruprotected void	 c_insert(EditLine *, int);
15093139Sruprotected void	 c_delbefore(EditLine *, int);
15193139Sruprotected void	 c_delafter(EditLine *, int);
15293139Sruprotected int	 c_gets(EditLine *, char *);
15393139Sruprotected int	 c_hpos(EditLine *);
15493139Sru
15593139Sruprotected int	 ch_init(EditLine *);
15693139Sruprotected void	 ch_reset(EditLine *);
15793139Sruprotected int	 ch_enlargebufs(EditLine *, size_t);
15893139Sruprotected void	 ch_end(EditLine *);
15993139Sru
16093139Sru#endif /* _h_el_chared */
16193139Sru