Beispiel #1
0
void movebol()
{
int i;
    for(i=bol();i<current_loc;i++){
	backspace();
    }
    current_loc = bol();
}
Beispiel #2
0
void
mfc_term_view::recall_line()   // bound to Enter in hist_view
{
  CString txt = grab_line();
  term_view->set_command(txt);
  long i = bol(0);     // get first char of current line
  if (i == bol(1)) {  // this line typed at end: send it
    term_view->send_or_copy();
    i = eob();
  } else if (term_view->is_visible) {
    CMDIFrameWnd *fw = (CMDIFrameWnd *)(the_boss.m_pMainWnd);
        fw->MDIActivate(term_view->GetParent());
  }
  GetRichEditCtrl().SetSel(i, i);
}
Beispiel #3
0
Datei: text.c Projekt: hankem/jed
static int is_paragraph_sep(void) /*{{{*/
{
   int ret;
   Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks;

   if ((h != NULL)
       && (h->par_sep != NULL))
     {
	if ((-1 == SLexecute_function(h->par_sep))
	    || (-1 == SLang_pop_integer(&ret)))
	  ret = -1;

	return ret;
     }

   push_spot ();
   (void) bol ();
   jed_skip_whitespace ();
   if (eolp ())
     {
	pop_spot ();
	return 1;
     }
   pop_spot ();
   return 0;
}
Beispiel #4
0
// byte order big to little address (4 or 8 bytes)
inline intptrj_t boa(intptrj_t arg)
   {
   if (sizeof(intptrj_t) == 4)
      return boi(arg);
   else
      return bol(arg);
   }
Beispiel #5
0
Datei: cmds.c Projekt: hankem/jed
/* the page up/down commands set cursor_motion to -1 because we do not
 want to use any goal column information */
int pagedown_cmd()
{
   int col, this_line, this_point;
   int n;

   Cursor_Motion = -1;
   if (IN_MINI_WINDOW)
     {
	scroll_completion (1);
	return 1;
     }

   if (eobp())
     {
	eob_bob_error (3);
	return 1;
     }

   n = JWindow->rows;
   if ((CBuf != JWindow->buffer) || (n == 1))
     {
	return next_visible_lines (n);
     }

   if (JWindow->trashed)
     {
	update (NULL, 0, 0, 1);
	if (JWindow->trashed) return next_visible_lines (n);
     }

   /* This is ugly. */

   this_line = LineNum;
   this_point = Point;

   col = calculate_column ();
   if (goto_bottom_of_window ())
     {
	recenter (&Number_One);
     }

   goto_column1 (&col);

   if ((Last_Key_Function == (FVOID_STAR) pageup_cmd)
       && (Jed_This_Key_Function == (FVOID_STAR) pagedown_cmd))
     {
	goto_line (&Last_Page_Line);
	if (Last_Page_Point < CLine->len)
	  Point = Last_Page_Point;
     }
   else if (CLine->next == NULL) eol();
   else bol ();

   Last_Page_Line = this_line;
   Last_Page_Point = this_point;

   return(1);
}
Beispiel #6
0
Datei: text.c Projekt: hankem/jed
/* returns 0 if to wrapped, 1 if wrapped, -1 if error */
static int wrap_line1(int format, int trim) /*{{{*/
{
   unsigned char *p, *pmin;
   int col;

   if (format)
     pmin = text_format_line();
   else
     {
	bol ();
	/* Ignore leading whitespace */
	pmin = jed_skip_whitespace ();
	/* pmin = CLine->data; */
     }
   if (pmin == NULL)
     return -1;

   point_column(Buffer_Local.wrap_column - 1);
   col = calculate_column();
   if ((col < Buffer_Local.wrap_column) && eolp ())
     return 0;

   p = CLine->data + Point;

   while(p > pmin)
     {
	if ((*p == ' ') || (*p == '\t')) break;
	p--;
     }

   if (p == pmin)
     {
	/* that failed, so go the other way */
	p = CLine->data + CLine->len;
	while(pmin < p)
	  {
	     if ((*pmin == ' ') || (*pmin == '\t')) break;
	     pmin++;
	  }
	if (p == pmin) return 0;
	p = pmin;
     }

   jed_position_point (p);

   if (trim && (-1 == jed_trim_whitespace()))
     return -1;

   if (-1 == jed_insert_newline())
     return -1;

   jed_up(1);
   return 1;
}
Beispiel #7
0
/*
** do the delete but without doing the refresh
*/
void nrdeletechar()
{
int i;
    /*
    ** dont delete past the beginning of the line
    */
    if(--end_of_buffer < bol()) end_of_buffer = bol();
    /*
    ** how the hell can this happen?
    ** check it out later. I must have done it for some reason
    */
    if(end_of_buffer < current_loc) {
	backspace();
	current_loc = end_of_buffer;
    }
    /*
    ** delete the character by shifting the rest of the characters back
    */
    for(i=current_loc;i<end_of_buffer;i++){
	input_buffer[i] = input_buffer[i+1];
    }
}
Beispiel #8
0
Datei: cmds.c Projekt: hankem/jed
int pageup_cmd (void)
{
   int col, this_line, this_point;
   int n;

   Cursor_Motion = -1;

   if (IN_MINI_WINDOW)
     {
	scroll_completion (-1);
	return 1;
     }

   if (bobp())
     {
	eob_bob_error (-3);
	return 1;
     }

   n = JWindow->rows;
   if ((CBuf != JWindow->buffer) || (n == 1))
     {
	return prev_visible_lines (n);
     }

   if (JWindow->trashed)
     {
	update (NULL, 0, 0, 1);
	if (JWindow->trashed) return prev_visible_lines (n);
     }

   this_line = LineNum;
   this_point = Point;
   col = calculate_column ();
   goto_top_of_window ();
   (void) goto_column1(&col);
   recenter(&JWindow->rows);

   if ((Last_Key_Function == (FVOID_STAR) pagedown_cmd)
       && (Jed_This_Key_Function == (FVOID_STAR) pageup_cmd))
     {
	goto_line (&Last_Page_Line);
	if (Last_Page_Point < CLine->len)
	  Point = Last_Page_Point;
     }
   else
     bol (); /* something like: Point = point_column(JWindow->column) better? */
   Last_Page_Line = this_line;
   Last_Page_Point = this_point;
   return(1);
}
Beispiel #9
0
Datei: cmds.c Projekt: hankem/jed
/* indent line to column n */
void indent_to(int n)
{
   int m;

   get_current_indent(&m);

   if (n != m)
     {
	bol ();
	if (-1 == jed_trim_whitespace())
	  return;
	if (n >= 0) insert_whitespace(&n);
     }
}
Beispiel #10
0
Datei: text.c Projekt: hankem/jed
int backward_paragraph(void) /*{{{*/
{
   Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks;

   if ((h != NULL)
       && (h->backward_paragraph_hook != NULL))
     {
	if (0 == SLexecute_function (h->backward_paragraph_hook))
	  return 1;

	return -1;
     }

   bol ();
   while ((1 == is_paragraph_sep ())
	  && jed_up (1))
     bol ();

   while ((0 == is_paragraph_sep ())
	  && jed_up (1))
     bol ();

   return 1;
}
Beispiel #11
0
    static void dump (const basic_state_machine<CharT> &state_machine_, ostream &stream_)
    {
        typename basic_state_machine<CharT>::iterator iter_ =
            state_machine_.begin ();
        typename basic_state_machine<CharT>::iterator end_ =
            state_machine_.end ();

        for (std::size_t dfa_ = 0, dfas_ = state_machine_.size ();
            dfa_ < dfas_; ++dfa_)
        {
            const std::size_t states_ = iter_->states;

            for (std::size_t i_ = 0; i_ < states_; ++i_)
            {
                state (stream_);
                stream_ << i_ << std::endl;

                if (iter_->end_state)
                {
                    end_state (stream_);
                    stream_ << iter_->id;
                    dfa (stream_);
                    stream_ << iter_->goto_dfa;
                    stream_ << std::endl;
                }

                if (iter_->bol_index != npos)
                {
                    bol (stream_);
                    stream_ << iter_->bol_index << std::endl;
                }

                if (iter_->eol_index != npos)
                {
                    eol (stream_);
                    stream_ << iter_->eol_index << std::endl;
                }

                const std::size_t transitions_ = iter_->transitions;

                if (transitions_ == 0)
                {
                    ++iter_;
                }

                for (std::size_t t_ = 0; t_ < transitions_; ++t_)
                {
                    std::size_t goto_state_ = iter_->goto_state;

                    if (iter_->token.any ())
                    {
                        any (stream_);
                    }
                    else
                    {
                        open_bracket (stream_);

                        if (iter_->token._negated)
                        {
                            negated (stream_);
                        }

                        string charset_;
                        CharT c_ = 0;

                        escape_control_chars (iter_->token._charset,
                            charset_);
                        c_ = *charset_.c_str ();

                        if (!iter_->token._negated &&
                            (c_ == '^' || c_ == ']'))
                        {
                            stream_ << '\\';
                        }

                        stream_ << charset_;
                        close_bracket (stream_);
                    }

                    stream_ << goto_state_ << std::endl;
                    ++iter_;
                }

                stream_ << std::endl;
            }
        }
    }
Beispiel #12
0
void
mfc_term_view::select_lines(int off1, int off2)
{
  GetRichEditCtrl().SetSel(bol(off1), bol(off2));
}
Beispiel #13
0
long
mfc_term_view::eol(int offset)
{
  long i = bol(offset);
  return i + GetRichEditCtrl().LineLength(i);
}
Beispiel #14
0
    static void dump_ex(const typename char_state_machine::dfa &dfa_,
        ostream &stream_)
    {
        const std::size_t states_ = dfa_._states.size();
        const id_type bol_index_ = dfa_._bol_index;
        typename dfa_state::id_type_string_token_map::const_iterator iter_;
        typename dfa_state::id_type_string_token_map::const_iterator end_;

        for (std::size_t i_ = 0; i_ < states_; ++i_)
        {
            const dfa_state &state_ = dfa_._states[i_];

            state(stream_);
            stream_ << i_ << std::endl;

            if (state_._end_state)
            {
                end_state(stream_);

                if (state_._push_pop_dfa == dfa_state::push_dfa)
                {
                    push(stream_);
                    stream_ << state_._push_dfa;
                }
                else if (state_._push_pop_dfa == dfa_state::pop_dfa)
                {
                    pop(stream_);
                }

                id(stream_);
                stream_ << static_cast<std::size_t>(state_._id);
                user_id(stream_);
                stream_ << static_cast<std::size_t>(state_._user_id);
                dfa(stream_);
                stream_ << static_cast<std::size_t>(state_._next_dfa);
                stream_ << std::endl;
            }

            if (i_ == 0 && bol_index_ != char_state_machine::npos())
            {
                bol(stream_);
                stream_ << static_cast<std::size_t>(bol_index_) << std::endl;
            }

            if (state_._eol_index != char_state_machine::npos())
            {
                eol(stream_);
                stream_ << static_cast<std::size_t>(state_._eol_index) <<
                    std::endl;
            }

            iter_ = state_._transitions.begin();
            end_ = state_._transitions.end();

            for (; iter_ != end_; ++iter_)
            {
                string_token token_ = iter_->second;

                open_bracket(stream_);

                if (!iter_->second.any() && iter_->second.negatable())
                {
                    token_.negate();
                    negated(stream_);
                }

                string chars_;
                typename string_token::range_vector::const_iterator
                    ranges_iter_ = token_._ranges.begin();
                typename string_token::range_vector::const_iterator
                    ranges_end_ = token_._ranges.end();

                for (; ranges_iter_ != ranges_end_; ++ranges_iter_)
                {
                    if (ranges_iter_->first == '-' ||
                        ranges_iter_->first == '^' ||
                        ranges_iter_->first == ']')
                    {
                        stream_ << '\\';
                    }

                    chars_ = string_token::escape_char
                        (ranges_iter_->first);

                    if (ranges_iter_->first != ranges_iter_->second)
                    {
                        if (ranges_iter_->first + 1 < ranges_iter_->second)
                        {
                            chars_ += '-';
                        }

                        if (ranges_iter_->second == '-' ||
                            ranges_iter_->second == '^' ||
                            ranges_iter_->second == ']')
                        {
                            stream_ << '\\';
                        }

                        chars_ += string_token::escape_char
                            (ranges_iter_->second);
                    }

                    stream_ << chars_;
                }

                close_bracket(stream_);
                stream_ << static_cast<std::size_t>(iter_->first) <<
                    std::endl;
            }

            stream_ << std::endl;
        }
    }
Beispiel #15
0
void	rm_line(t_elem *e)
{
  bol(e);
  my_tputs(e->cap[CD]);
}
Beispiel #16
0
Datei: text.c Projekt: hankem/jed
/* format paragraph and if Prefix argument justify_hook is called. */
int text_format_paragraph () /*{{{*/
{
   unsigned char *p;
   int indent_col, col;
   Line *end, *beg, *next;
   Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks;

   CHECK_READ_ONLY

     if ((h != NULL)
	 && (h->format_paragraph_hook != NULL))
       return SLexecute_function (h->format_paragraph_hook);

   push_spot();

   get_current_indent(&indent_col);
   if (indent_col + 1 >= Buffer_Local.wrap_column)
     indent_col = 0;

   if (-1 == mark_paragraph (&beg, &end))
     goto return_error;

   get_current_indent (&col);
   /* col is the indentation of the first line of the paragraph-- don't change it */

   bol ();
   while (CLine != end)
     {
	if (-1 == wrap_line1 (0, 0))
	  goto return_error;

	if (0 == jed_down (1))
	  break;
     }

   while ((CLine != beg)
	  && (0 != jed_up (1)))
     ;

   if (col + 1 >= Buffer_Local.wrap_column)
     indent_to (indent_col);

   bol ();

   /* Now loop formatting as we go until the end is reached */
   while(CLine != end)
     {
	int status;

	/* eol(); */
	if (CLine != beg) indent_to(indent_col);
	status = wrap_line1(1, 1);
	if (status == -1)
	  goto return_error;

	if (status == 1)
	  {
	     (void) jed_down(1);
	     /* indent_to(indent_col); */
	     continue;
	  }
	else if (CLine->next == end)
	  break;

	next = CLine->next;
	if (next != end)
	  {
	     unsigned char *pmax;

	     /* Now count the length of the word on the next line. */
	     (void) jed_down(1);       /* at bol too */

	     if (-1 == jed_trim_whitespace())
	       goto return_error;

	     p = CLine->data;
	     pmax = jed_eol_position (CLine);

	     /* FIXME for other multibyte whitespace chars */
	     while ((p < pmax) && (*p > ' '))
	       p++;

	     jed_up(1);		       /* at eol too */

	     col = calculate_column();

	     /* FIXME for multibyte */
	     if ((p - next->data) + col < Buffer_Local.wrap_column - 1)
	       {
		  if (-1 == _jed_replace_wchar (' '))
		    goto return_error;
	       }
	     else
	       {
		  (void) jed_down(1);
	       }
	  }
     }
   if (Repeat_Factor != NULL)
     {
	SLang_run_hooks("format_paragraph_hook", 0);
	Repeat_Factor = NULL;
     }
   pop_spot();
   return(1);

return_error:
   pop_spot ();
   return -1;
}
Beispiel #17
0
Datei: text.c Projekt: hankem/jed
/* This routine deletes multiple spaces except those following a period, '?'
 * or a '!'.
   Returns the address of beginning of non whitespace */
static unsigned char *text_format_line(void) /*{{{*/
{
   unsigned char *p, *pmin, *pmax;
   unsigned int point_min;

   bol (); jed_skip_whitespace ();
   point_min = Point;

   p = CLine->data + point_min;
   pmax = jed_eol_position (CLine);
   while (p < pmax)
     {
	if (*p == '\t')
	  {
	     jed_position_point (p);
	     if (-1 == _jed_replace_wchar (' '))
	       return NULL;

	     /* In case the underlying pointer changed, reset these */
	     p = CLine->data + Point;
	     pmax = jed_eol_position (CLine);
	  }
	p++;
     }

   pmin = CLine->data + point_min;
   p = pmax - 1;

   while (p > pmin)
     {
	unsigned char *p1;
	unsigned int n;

	if ((*p != ' ') && (*p != '\t'))
	  {
	     p--;
	     continue;
	  }

	jed_position_point (p);
	p1 = jed_bskip_whitespace ();

	if (p == p1)
	  {
	     p--;		       /* single space */
	     continue;
	  }

	/* multiple spaces */
	n = p - p1;
	p = p1;
	p1--;
	if ((*p1 == '.') || (*p1 == '?') || (*p1 == '!'))
	  n--;

	if (n)
	  {
	     jed_position_point (p);
	     jed_del_nbytes (n);
	     pmin = CLine->data + point_min;
	     p = CLine->data + Point;
	  }

	p--;
     }

   return pmin;
}