int save_restriction( void ) { int rv; EmacsBuffer *b = bf_cur; EmacsBuffer *b2; Marker ml( bf_cur, bf_cur->b_mode.md_headclip, 0); Marker mh( bf_cur, bf_cur->unrestrictedSize() + 1 - bf_cur->b_mode.md_tailclip, 1); rv = progn_command(); b2 = bf_cur; b->b_mode.md_headclip = ml.to_mark(); b->b_mode.md_tailclip = bf_cur->unrestrictedSize() + 1 - mh.to_mark(); if( dot < bf_cur->first_character() ) set_dot( bf_cur->first_character() ); if( dot > bf_cur->num_characters() ) set_dot( bf_cur->num_characters() + 1 ); if( bf_cur != b2 ) b2->set_bf(); cant_1win_opt = 1; return rv; }
int replace_string_helper( EmacsSearch::sea_type RE, const EmacsString &prompt ) { // // perform either a query replace or a normal replace // int replaced = 0; int olddot = dot; EmacsString old; old = getstr( prompt ); sea_glob.compile( old, RE ); EmacsString new_string; if( ml_err ) return 0; new_string = getstr("New string: "); int np = sea_glob.search( 1, dot ); while( np > 0 ) { set_dot( np ); sea_glob.search_replace_once( new_string ); replaced++; np = sea_glob.search( 1, dot ); #if 0 // make sure the search actually moves on if( dot == np ) { set_dot( dot + 1 ); np = sea_glob.search( 1, dot ); } #endif } set_dot( olddot ); if( replaced != 0 ) { if( interactive() ) { void_result(); message( FormatString("Replaced %d occurrences") << replaced ); cant_1line_opt = 1; } else { ml_value = replaced; } } else error( FormatString("No replacements done for \"%s\"") << last_search_string.asString() ); return 0; }
int end_of_line( void ) { int ndot = scan_bf_for_lf( dot ,1 ); if( dot != ndot ) { set_dot (ndot); if( bf_cur->char_at (ndot - 1) == '\n' ) { dot_left( 1 ); if( dot < bf_cur->first_character() ) set_dot( bf_cur->first_character() ); } } return 0; }
int delete_white_space( void ) { int p1 = dot; int p2 = bf_cur->num_characters(); // space, tab, EN space (0x2002) while( p1 <= p2 && unicode_is_space( bf_cur->char_at( p1 ) ) ) { p1++; } p2 = dot; do { p2--; } while( p2 >= bf_cur->first_character() && unicode_is_space( bf_cur->char_at( p2 ) ) ); set_dot (p2 + 1); if( (p1 = p1 - p2 - 1) > 0 ) { bf_cur->del_frwd (dot, p1); } return 0; }
static void line_move( int up, int n ) { static int lastcol; int ndot; int col = 1; int lim = bf_cur->num_characters() + 1; if( n == 0 ) return; if( n < 0 ) { n = -n; up = ! up; } if( up ) n = -n - 1; if( last_proc != next_line && last_proc != previous_line ) lastcol = (track_eol != 0 && dot < lim && bf_cur->char_at (dot) == '\n') ? 9999 : cur_col(); ndot = scan_bf_for_lf( dot, n ); while( col < lastcol && ndot < lim ) { n = bf_cur->char_at( ndot ); if( n == '\n' ) break; if( n == '\t' ) col = ((col - 1) / bf_cur->b_mode.md_tabsize + 1) * bf_cur->b_mode.md_tabsize + 1; else if( control_character( n ) ) col += ctl_arrow != 0 ? (term_deccrt != 0 && (n == ctl('k') || n == ctl('l') || n == '\r' || n == '\033') ) ? 1 : 2 : 4; else col++; ndot++; } set_dot( ndot ); dot_col = col; col_valid = 1; }
int region_around_match( int n ) { if( n < 0 || n > sea_glob.get_number_of_groups() ) { error( "Out-of-bounds argument to region-around-match" ); return 0; } bf_cur->set_mark( sea_glob.get_start_of_group( n ), 0, false ); set_dot( sea_glob.get_end_of_group( n ) ); return 0; }
void draw(void){ unsigned char i; first_page(); if(situation==0){ for(i=0;i<snakelen;i++){ set_dot(snakex[i],snakey[i]); } for(i=0;i<6;i++){ if(food[i]){ set_dot(foodx[i],foody[i]); } } }else if(situation==1){ for(i=0;i<32;i++){ LEDarraydata[i]=die[i]; } }else if(situation==3){ for(i=0;i<32;i++){ LEDarraydata[i]=win[i]; } } }
int exchange_dot_and_mark( void ) { int old_dot = dot; if( !bf_cur->b_mark.isSet() ) error( FormatString(no_mark_set_str) << bf_cur->b_buf_name); else { set_dot( bf_cur->b_mark.to_mark() ); bf_cur->set_mark( old_dot, 0, bf_cur->b_gui_input_mode_set_mark ); } return 0; }
void gui_set_dot( int n ) { #if DBG_EXEC if( dbg_flags&DBG_EXEC ) _dbg_msg( FormatString("GUI_set_dot in %s to %d from %d") << bf_cur->b_buf_name << n << dot ); #endif // force shift_state to on Save<bool> saved_shift_state( &shift_state ); shift_state = true; // set dot knowing that the region will // be set if nessesary set_dot( n ); }
int backward_character( void ) { int count = arg; if( cur_exec != 0 && cur_exec->p_nargs > 0 ) count = count * numeric_arg (1); dot_left (count); if( dot < bf_cur->first_character() ) { set_dot( bf_cur->first_character() ); error( "You are at the beginning of the buffer"); } return 0; }
int search_forward( void ) { EmacsString str; int np; if( arg <= 0 ) arg = 1; str = getstr("Search for: "); np = sea_glob.search( str, arg, dot, EmacsSearch::sea_type__string ); if( np == 0 && ! ml_err ) error(FormatString("Cannot find \"%s\"") << last_search_string.asString() ); else if( np > 0 ) set_dot( np ); return 0; }
int forward_character( void ) { int count = arg; if( cur_exec != 0 && cur_exec->p_nargs > 0 ) count = count * numeric_arg (1); dot_right (count); if( dot > bf_cur->num_characters() + 1 ) { set_dot (bf_cur->num_characters() + 1); error( "You are at the end of the buffer."); } return 0; }
int re_search_reverse_helper( EmacsSearch::sea_type RE ) { int np; EmacsString str; if( arg <= 0 ) arg = 1; if( RE == EmacsSearch::sea_type__RE_extended ) str = getstr("Reverse ERE search for: "); else str = getstr("Reverse RE search for: "); np = sea_glob.search( str, -arg, dot, RE ); if( np == 0 && ! ml_err ) error(FormatString("Cannot find \"%s\"") << last_search_string.asString() ); else if( np > 0 ) set_dot( np ); return 0; }
int search_reverse( void ) { if( arg <= 0 ) { arg = 1; } EmacsString str = getstr( "Reverse search for: " ); int np = sea_glob.search( str, -arg, dot, EmacsSearch::sea_type__string ); if( np == 0 && ! ml_err ) { error( FormatString("Cannot find \"%s\"") << last_search_string.asString() ); } else { if( np > 0 ) { set_dot( np ); } } return 0; }
static void del_to_buf ( int n, DeleteToWhere_t where, int del_doner, const EmacsString &name ) { int p = dot; EmacsBuffer *old = bf_cur; EmacsBuffer *kill = EmacsBuffer::find( name ); if( kill == NULL ) kill = EMACS_NEW EmacsBuffer( name ); if( where == ReplaceBuffer ) kill->erase_bf(); if( n < 0 ) { n = -n; p = p - n; } if( p < bf_cur->first_character() ) { n = n + p - bf_cur->first_character(); p = bf_cur->first_character(); } if( p + n > bf_cur->num_characters() + 1 ) n = bf_cur->num_characters() + 1 - p; if( n <= 0 ) return; bf_cur->gap_to( p ); kill->set_bf(); switch( where ) { case PrependToBuffer: // prepend to the start of the buffer to the start of the buffer set_dot( bf_cur->first_character() ); bf_cur->ins_cstr( old->ref_char_at( p ), n ); // leave dot at the start set_dot( bf_cur->first_character() ); break; case ReplaceBuffer: case AppendToBuffer: // append to the end of the buffer set_dot( bf_cur->num_characters() + 1 ); bf_cur->ins_cstr( old->ref_char_at( p ), n ); // move dot to the end of the buffer set_dot( bf_cur->num_characters() + 1 ); break; } old->set_bf(); if( del_doner ) { bf_cur->del_frwd( p, n ); set_dot (p); } }
int beginning_of_line( void ) { set_dot (scan_bf_for_lf (dot, -1)); return 0; }
void clear(void) { for(uint8_t x = 0; x < WIDTH; x++) for(uint8_t y = 0; y < HEIGHT; y++) set_dot(x, y, false); }