Exemplo n.º 1
0
/* Insert the character at the current position and move the text at its right
 * whatever the insert/overwrite mode is.
 * This function doesn't change the current position of the pointer.
 */
int intercalate_char(int c)
{
	if (warn_if_readonly_buffer())
		return FALSE;

	/*
	 * Resize the line if required.
	 */
	if (cur_wp->pointp->size + 1 >= cur_wp->pointp->maxsize)
		resize_line(cur_wp, cur_wp->pointp,
			    cur_wp->pointp->maxsize + 10);
	/*
	 * Move the line text one position forward after the
	 * point if required.
	 * This code assumes that memmove(d, s, 0) does nothing.
	 */
	memmove(cur_wp->pointp->text + cur_wp->pointo + 1,
		cur_wp->pointp->text + cur_wp->pointo,
		cur_wp->pointp->size - cur_wp->pointo);

	undo_save(UNDO_REMOVE_CHAR, cur_wp->pointn, cur_wp->pointo, 0, 0);
	cur_wp->pointp->text[cur_wp->pointo] = c;

	++cur_wp->pointp->size;

	cur_bp->flags |= BFLAG_MODIFIED;

	if (cur_bp->flags & BFLAG_FONTLOCK)
		font_lock_reset_anchors(cur_bp, cur_wp->pointp);

	return TRUE;
}
Exemplo n.º 2
0
int insert_tab(void)
{
	if (warn_if_readonly_buffer())
		return FALSE;

	if (!lookup_bool_variable("expand-tabs"))
		insert_char('\t');
	else
		insert_expanded_tab();

	return TRUE;
}
Exemplo n.º 3
0
/*
 * Insert the character `c' at the current point position
 * into the current buffer.
 */
int insert_char(int c)
{
	windowp wp;
	int pointo;

	if (warn_if_readonly_buffer())
		return FALSE;

	if (cur_bp->flags & BFLAG_OVERWRITE) {
		if (cur_wp->pointo < cur_wp->pointp->size) {
			/*
			 * XXX Emacs behaviour:
			 * "Before a tab, such characters insert until
			 * the tab is filled in."
			 */
			undo_save(UNDO_REPLACE_CHAR,
				  cur_wp->pointn, cur_wp->pointo,
				  cur_wp->pointp->text[cur_wp->pointo], 0);
			cur_wp->pointp->text[cur_wp->pointo] = c;
			++cur_wp->pointo;

			cur_bp->flags |= BFLAG_MODIFIED;

			if (cur_bp->flags & BFLAG_FONTLOCK)
				font_lock_reset_anchors(cur_bp, cur_wp->pointp);

			return TRUE;
		}
		/*
		 * Fall through the "insertion" mode of a character
		 * at the end of the line, since it is totally
		 * equivalent also in "overwrite" mode.
		 */
	}

	(void)intercalate_char(c);

	pointo = cur_wp->pointo;

	/*
	 * Scan all the windows searching for points
	 * pointing at the modified line.
	 */
	for (wp = head_wp; wp != NULL; wp = wp->next)
		if (wp->pointp == cur_wp->pointp && wp->pointo >= pointo)
			++wp->pointo;

	if (cur_bp->markp == cur_wp->pointp && cur_bp->marko >= pointo)
		++cur_bp->marko;

	return TRUE;
}
Exemplo n.º 4
0
Arquivo: line.c Projeto: M1lan/zile
static bool
insert_tab (void)
{
  if (warn_if_readonly_buffer ())
    return false;

  if (get_variable_bool ("indent-tabs-mode"))
    insert_char ('\t');
  else
    insert_expanded_tab ();

  return true;
}
Exemplo n.º 5
0
static int kill_line(int literally)
{
  if (!eolp()) {
    if (warn_if_readonly_buffer())
      return FALSE;

    undo_save(UNDO_INSERT_BLOCK, cur_bp->pt,
              astr_len(cur_bp->pt.p->item) - cur_bp->pt.o, 0);
    undo_nosave = TRUE;
    while (!eolp()) {
      kill_ring_push(following_char());
      FUNCALL(delete_char);
    }
    undo_nosave = FALSE;

    thisflag |= FLAG_DONE_KILL;

    if (!literally)
      return TRUE;
  }

  if (list_next(cur_bp->pt.p) != cur_bp->lines) {
    if (!FUNCALL(delete_char))
      return FALSE;

    kill_ring_push('\n');

    thisflag |= FLAG_DONE_KILL;

    return TRUE;
  }

  minibuf_error("End of buffer");

  return FALSE;
}