📄 term.cc
字号:
/*line full: wraps if input _exceeds_ margin. stays put right after 79th charctrl-a-g nothingctrl-h-n action (^n affects next char)ctrl-o-z nothingctrl-[ affects next charalt- ansi?alt- switches to prev. task` 60~ 7e!@#$ 21 40 23 24%^&* 25 5e 26 2a() 28 29-=_+ 2d 3d 5f 2b[]\{}| 5b 5d 5c 7b 7d 7c;':" 4b 27 3a 22,./<>? 2c 2e 2f 3c 3e 3flocks all workctrls work (try alt?)keypad:/-*+ work goodnum_on works (shift has no effect)^scrlk dumps core!shift- dumps core too!*/char term::ctrl( u_int cursor, register char c ){ switch( c ) { case 0x00: nul(); break; /* */ case 0x01: soh(); break; /* */ case 0x02: stx(); break; /* */ case 0x03: etx(); break; /* */ case 0x04: eot(); break; /* */ case 0x05: enq(); break; /* */ case 0x06: ack(); break; /* */ case 0x07: bel(); break; /* */ case 0x08: bs( cursor ); break; /* */ case 0x09: ht( cursor ); break; /* */ case 0x0A: lf(); break; /* */ case 0x0B: vt(); break; /* */ case 0x0C: ff(); break; /* */ case 0x0D: cr( cursor ); break; /* */ case 0x0E: so(); break; /* */ case 0x0F: si(); break; /* */ case 0x10: dle(); break; /* */ case 0x11: xon(); break; /* */ case 0x12: dc2(); break; /* */ case 0x13: xoff(); break; /* */ case 0x14: dc4(); break; /* */ case 0x15: nak(); break; /* */ case 0x16: syn(); break; /* */ case 0x17: etb(); break; /* */ case 0x18: can(); break; /* */ case 0x19: em(); break; /* */ case 0x1A: sub(); break; /* */ case 0x1B: esc( cursor ); break; /* */ case 0x1C: fs(); break; /* */ case 0x1D: gs(); break; /* */ case 0x1E: rs(); break; /* */ case 0x1F: us(); break; /* */ } return c;}void term::ctrlalt( u_int cursor, register char c ) {}void term::altlock( u_int cursor, register char c ){ lock( cursor, c );}void term::ctrlpunc( u_int cursor, register char c ) {}void term::ctrlmath( u_int cursor, register char c ) {}void term::altund( u_int cursor ) {}void term::altmny( u_int cursor ) {}void term::altexc( u_int cursor ) {}void term::fire( u_int cursor, bool ) {}void term::accel( u_int cursor, bool ) {}void term::meta( u_int cursor, bool ) {}void term::hash( u_int cursor, register char ) {}char term::ascii_eval_hex( u_int cursor ){ int value; if( digits == 2 ) value = ascii_buffer[ 0 ] * 0x10 + ascii_buffer[ 1 ]; else value = ascii_buffer[ 0 ]; asc_hex = false; return pipe( cursor, value );}char term::ascii_eval( u_int cursor ){ int value; if( digits == 3 ) value = ( ascii_buffer[ 0 ] * 100 + ascii_buffer[ 1 ] * 10 + ascii_buffer[ 2 ] ) % 0x100; else if( digits == 2 ) value = ascii_buffer[ 0 ] * 10 + ascii_buffer[ 1 ]; else value = ascii_buffer[ 0 ]; asc_hex = false; return pipe( cursor, value );}void term::ascii( u_int cursor, int digit, bool adding ){ if( !adding ) { if( digits ) if( asc_hex ) ascii_eval_hex( cursor ); else ascii_eval( cursor ); return; } if( digits++ > 3 ) { ascii_eval( cursor ); digits = 1; } else if( digits == 3 && asc_hex ) { ascii_eval_hex( cursor ); digits = 1; } ascii_buffer[ digits - 1 ] = digit;}void term::ascii_hex( u_int cursor, int digit ){ if( digits++ > 3 ) // not hex { ascii_eval( cursor ); digits = 1; } else if( digits == 3 ) { bool x = asc_hex; ascii_eval_hex( cursor ); digits = x; // not cont'd if typed a letter just to call 2 digits hex } if(( asc_hex = digits )) // bool type reduces a 2 to true ? ascii_buffer[ digits - 1 ] = digit;}void term::select( u_int cursor, bool ) {}void term::lock( u_int cursor, int ) {}void term::pan( u_int cursor, int dir, bool flag ){ // dir: 0, arrow, page; flag: hold, normal, (real) fast switch( dir ) { case 4: { collapse( cursor ); } break; case 6: // add lines { expand( cursor ); } break; }}void term::mousekey( u_int cursor, char ){ // 0-9, + - * /, (.)}void term::submit( u_int cursor ) {}void term::full_screen( u_int cursor ) {}void term::run( u_int cursor ) {}void term::cell_new( u_int cursor ){ // currently untypable}void term::cell_del( u_int cursor ) {}void term::frame_new( u_int cursor ) {}void term::hide( u_int cursor ) {}void term::frame_del( u_int cursor ) {}void term::ht_back( u_int cursor ) {}void term::item( u_int cursor, bool ) {} // next or previousvoid term::task( u_int cursor, bool ) {}void term::taskset( u_int cursor, bool ) {}void term::highlight( u_int cursor, int ){ // dir: arrow, home/end, pgup/dn, alt?shift?arrow?}void term::indent( u_int cursor, bool ) {} // left or rightvoid term::skip( u_int cursor, int ) {} // arrow onlyvoid term::frame( u_int cursor, int ) {} // # of framevoid term::top( u_int cursor ) {}void term::bot( u_int cursor ) {}void term::paste( u_int cursor ) {}void term::copy( u_int cursor ) {}void term::exchange( u_int cursor ) {}void term::cut( u_int cursor ) {}void term::cut_append( u_int cursor ) {}void term::vol( u_int cursor, bool ) {} // up or downvoid term::res_change( u_int cursor, bool ) {}void term::longer( u_int cursor ) {}void term::shorter( u_int cursor ) {}void term::wider( u_int cursor ) {}void term::narrower( u_int cursor ) {}void term::snapshot( u_int cursor ) {}void term::snap_copy( u_int cursor ) {}void term::sysrq( u_int cursor ) {}void term::reveal( u_int cursor ) {}void term::exit( u_int cursor ) { exiting = true; }void term::core_dump( u_int cursor ) {}void term::beep(){// system( "./bel.sh" );/* FILE* tty = fopen( "/dev/tty1", "w" ); fprintf( tty, "\007" ); fclose( tty );*/}void term::boot( u_int cursor ) {}void term::func( u_int cursor, register int f, register int shift ){ switch( f ) { case 1: break; case 2: break; case 3: rows = s -> load( "file.txt" ); set_each_line( s -> top ); for_each_cursor( &term::home_cursor ); clear(); for(; xrow < note::rows && xrow < rows; xrow++ ) { write( x_here -> text, 0, xrow ); xhere = ( u_int )( x_here -> next ); } xrow = 0; xhere = ( u_int )( s -> top ); break; case 4: s -> save( "file.txt" ); break; case 5: break; case 6: break; case 7: break; case 8: break; case 9: break; case 10: break; case 11: break; case 12: break; }}void term::meta_ctrlesc( u_int cursor ) {}void term::meta_altesc( u_int cursor ) {}void term::meta_ctrlaltshift( u_int cursor ) {}void term::meta_altarrow( u_int cursor, int ) {}void term::meta_althome( u_int cursor ) {}void term::meta_altend( u_int cursor ) {}void term::meta_altpgup( u_int cursor ) {}void term::meta_altpgdn( u_int cursor ) {}void term::meta_altfunc( u_int cursor, int ) {}void term::meta_altnum( u_int cursor, int ) {}void term::meta_ctrlnum( u_int cursor, int ) {}void term::setcol( u_int cursor ){}void term::arrow( u_int cursor, register int dir ){ switch( dir ) { case 8: if( _row-- > 0 ) // not implememted for cursor > 0 if expansion differs { _here = ( u_int )( __here -> last ); if( _row == _orig - 1 ) _orig--; if( cursor == 0 ) { clear(); int it = xrow - xorig; for(; it > 0; it-- ) { xhere = ( u_int )( x_here -> last ); } for(; it < note::rows && it < rows - xorig; it++ ) { write( x_here -> text, 0, it ); if( it == rows - xorig - 1 ) break; xhere = ( u_int )( x_here -> next ); } for(; it > xrow - xorig; it-- ) { xhere = ( u_int )( x_here -> last ); } } if( _pcol > __here -> length ) _col = __here -> length; else _col = _pcol; if( cursor == 0 ) repos( xcol, xrow - xorig ); } else _row++; break; case 2: if( _row++ < rows - 1 ) { _here = ( u_int )( __here -> next ); if( _row - _orig == note::rows ) _orig++; if( cursor == 0 ) { clear(); int it = xrow - xorig; for(; it > 0; it-- ) { xhere = ( u_int )( x_here -> last ); } for(; it < note::rows && it < rows - xorig; it++ ) { write( x_here -> text, 0, it ); if( it == rows - xorig - 1 ) break; xhere = ( u_int )( x_here -> next ); } for(; it > xrow - xorig; it-- ) { xhere = ( u_int )( x_here -> last ); } } if( _pcol > __here -> length ) _col = __here -> length; else _col = _pcol; if( cursor == 0 ) repos( xcol, xrow - xorig ); } else _row--; break; case 4: if( _col-- > 0 ) { _pcol = _col; if( cursor == 0 ) repos( xcol, xrow - xorig ); } else _pcol = ++_col; break; // previously didn't set pcol case 6: if( _col++ < __here -> length ) { _pcol = _col; if( cursor == 0 ) repos( xcol, xrow - xorig ); } else _pcol = --_col; break; // previously didn't set pcol case 5: for( _col = 0; _col < __here -> length; _col++ ) if( __here -> text[ _col ] != ' ' ) break; _pcol = _col; if( cursor == 0 ) repos( xcol, xrow - xorig ); } redraw();}void term::ins( u_int cursor ){ if( __here -> length == cols ) return; __here -> ins( _col, ' ' ); for_each_cursor_right( _row, _col, &term::inc_col ); if( cursor == 0 ) repos( xcol, xrow - xorig ); else if( _row >= xorig + note::rows || _row < xorig ) return; repos( 0, _row - xorig ); printf( "0x1B[k" ); // erase to eol fflush( stdout ); write( __here -> text, 0, _row - xorig ); repos( xcol, xrow - xorig );}void term::home( u_int cursor ){ _col = _pcol = 0; repos( xcol, xrow - xorig );}void term::end( u_int cursor ){ _col = _pcol = __here -> length; repos( xcol, xrow - xorig );}void term::pgup( u_int cursor ) {}void term::pgdn( u_int cursor ) {}void term::pause( u_int cursor ){ exiting = true;}void term::esc( u_int cursor ) {} // ?void term::prtsc( u_int cursor ){}void term::cbreak( u_int cursor ) {}char term::hex( u_int cursor, register char c ){ return write_hex( c );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -