Пример #1
0
/*
 * Add a character, checking for word wrapping.
 * Check to see if we're past fillcol, and if so,
 * justify this line. As a last step, justify the line.
 */
int
fillword (int f, int n, int k)
{
  register char c;
  register int col, i, nce;

  for (i = col = 0; col <= fillcol; ++i, ++col)
    {
      if (i == curwp->w_dot.o)
	return selfinsert (f, n, k);
      c = lgetc (curwp->w_dot.p, i);
      if (c == '\t')
	col += (tabsize - col % tabsize) - 1;
      else if (ISCTRL (c) != FALSE)
	++col;
    }
  if (curwp->w_dot.o != llength (curwp->w_dot.p))
    {
      selfinsert (f, n, k);
      nce = llength (curwp->w_dot.p) - curwp->w_dot.o;
    }
  else
    nce = 0;
  curwp->w_dot.o = i;

  if ((c = lgetc (curwp->w_dot.p, curwp->w_dot.o)) != ' ' && c != '\t')
    do
      {
	backchar (FALSE, 1, KRANDOM);
      }
    while ((c = lgetc (curwp->w_dot.p, curwp->w_dot.o)) != ' '
	   && c != '\t' && curwp->w_dot.o > 0);

  if (curwp->w_dot.o == 0)
    do
      {
	forwchar (FALSE, 1, KRANDOM);
      }
    while ((c = lgetc (curwp->w_dot.p, curwp->w_dot.o)) != ' '
	   && c != '\t' && curwp->w_dot.o < llength (curwp->w_dot.p));

  delwhite (FALSE, 1, KRANDOM);
  backdel (FALSE, 1, KRANDOM);
  lnewline ();
  curwp->w_dot.o = llength (curwp->w_dot.p) - nce;
  curwp->w_flag |= WFMOVE;
  if (nce == 0 && curwp->w_dot.o != 0)
    return (fillword (f, n, k));
  return (TRUE);
}
Пример #2
0
Файл: zle_vi.c Проект: Osse/zsh
int
viquotedinsert(char **args)
{
#ifndef HAS_TIO
    struct sgttyb sob;
#endif

    spaceinline(1);
    zleline[zlecs] = '^';
    zrefresh();
#ifndef HAS_TIO
    sob = shttyinfo.sgttyb;
    sob.sg_flags = (sob.sg_flags | RAW) & ~ECHO;
    ioctl(SHTTY, TIOCSETN, &sob);
#endif
    getfullchar(0);
#ifndef HAS_TIO
    zsetterm();
#endif
    foredel(1, 0);
    if(LASTFULLCHAR == ZLEEOF)
	return 1;
    else
	return selfinsert(args);
}
Пример #3
0
void
viquotedinsert(void)
{
#ifndef WINNT
#ifndef HAS_TIO
    struct sgttyb sob;
#endif
#endif /* WINNT */

    spaceinline(1);
    line[cs] = '^';
    refresh();
#ifndef WINNT
#ifndef HAS_TIO
    sob = shttyinfo.sgttyb;
    sob.sg_flags = (sob.sg_flags | RAW) & ~ECHO;
    ioctl(SHTTY, TIOCSETN, &sob);
#endif
#endif /* WINNT */
    c = getkey(0);
#ifndef WINNT
#ifndef HAS_TIO
    setterm();
#endif
#endif /* WINNT */
    foredel(1);
    if(c < 0)
	feep();
    else
	selfinsert();
}
Пример #4
0
/* ARGSUSED */
int
fillword(int f, int n)
{
    char	c;
    int	col, i, nce;

    for (i = col = 0; col <= fillcol; ++i, ++col) {
        if (i == curwp->w_doto)
            return selfinsert(f, n);
        c = lgetc(curwp->w_dotp, i);
        if (c == '\t'
#ifdef NOTAB
                && !(curbp->b_flag & BFNOTAB)
#endif
           )
            col |= 0x07;
        else if (ISCTRL(c) != FALSE)
            ++col;
    }
    if (curwp->w_doto != llength(curwp->w_dotp)) {
        (void)selfinsert(f, n);
        nce = llength(curwp->w_dotp) - curwp->w_doto;
    } else
        nce = 0;
    curwp->w_doto = i;

    if ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' && c != '\t')
        do {
            (void)backchar(FFRAND, 1);
        } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' &&
                 c != '\t' && curwp->w_doto > 0);

    if (curwp->w_doto == 0)
        do {
            (void)forwchar(FFRAND, 1);
        } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' &&
                 c != '\t' && curwp->w_doto < llength(curwp->w_dotp));

    (void)delwhite(FFRAND, 1);
    (void)lnewline();
    i = llength(curwp->w_dotp) - nce;
    curwp->w_doto = i > 0 ? i : 0;
    curwp->w_rflag |= WFMOVE;
    if (nce == 0 && curwp->w_doto != 0)
        return (fillword(f, n));
    return (TRUE);
}
Пример #5
0
/*
 * Handle special C character - selfinsert then indent.
 */
int
cc_char(int f, int n)
{
	if (n < 0)
		return (FALSE);
	if (selfinsert(FFRAND, n) == FALSE)
		return (FALSE);
	return (cc_indent(FFRAND, n));
}
Пример #6
0
/*
 * If we are in the whitespace at the beginning of the line,
 * simply act as a regular tab. If we are not, indent
 * current line according to whitespace rules.
 */
int
cc_tab(int f, int n)
{
	int inwhitep = FALSE;	/* In leading whitespace? */
	
	inwhitep = in_whitespace(curwp->w_dotp, llength(curwp->w_dotp));

	/* If empty line, or in whitespace */
	if (llength(curwp->w_dotp) == 0 || inwhitep)
		return (selfinsert(f, n));

	return (cc_indent(FFRAND, 1));
}
Пример #7
0
/*
 * Hack to show matching paren.  Self-insert character, then show matching
 * character, if any.  Bound to "blink-and-insert".
 */
int
showmatch(int f, int n)
{
	int	i, s;

	for (i = 0; i < n; i++) {
		if ((s = selfinsert(FFRAND, 1)) != TRUE)
			return (s);
		/* unbalanced -- warn user */
		if (balance() != TRUE)
			ttbeep();
	}
	return (TRUE);
}
Пример #8
0
void quotedinsert() /**/
{
#ifndef TIO
struct sgttyb sob;
	sob = shttyinfo.sgttyb;
	sob.sg_flags = (sob.sg_flags|RAW) & ~ECHO;
	ioctl(SHTTY,TIOCSETN,&sob);
#endif
	c = getkey(0);
#ifndef TIO
	setterm();
#endif
	if (c) selfinsert(); else feep();
}
Пример #9
0
int
quotedinsert(char **args)
{
#ifndef HAS_TIO
    struct sgttyb sob;

    sob = shttyinfo.sgttyb;
    sob.sg_flags = (sob.sg_flags | RAW) & ~ECHO;
    ioctl(SHTTY, TIOCSETN, &sob);
#endif
    getfullchar(0);
#ifndef HAS_TIO
    zsetterm();
#endif
    if (LASTFULLCHAR == ZLEEOF)
	return 1;
    else
	return selfinsert(args);
}
Пример #10
0
Файл: kbd.c Проект: troglobit/mg
/*
 * This could be implemented as a keymap with everything defined as self-insert.
 */
int
quote(int f, int n)
{
	int	 c;

	key.k_count = 1;
	if ((key.k_chars[0] = getkey(TRUE)) >= '0' && key.k_chars[0] <= '7') {
		key.k_chars[0] -= '0';
		if ((c = getkey(TRUE)) >= '0' && c <= '7') {
			key.k_chars[0] <<= 3;
			key.k_chars[0] += c - '0';
			if ((c = getkey(TRUE)) >= '0' && c <= '7') {
				key.k_chars[0] <<= 3;
				key.k_chars[0] += c - '0';
			} else
				ungetkey(c);
		} else
			ungetkey(c);
	}
	return (selfinsert(f, n));
}
Пример #11
0
mod_export int
selfinsertunmeta(char **args)
{
    fixunmeta();
    return selfinsert(args);
}
Пример #12
0
void selfinsertunmeta() /**/
{
	c &= 0x7f;
	if (c == '\r') c = '\n';
	selfinsert();
}