⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 term.cc

📁 initial working phase of the design of said editor, featuring multicasting, advanced linux keyboard
💻 CC
📖 第 1 页 / 共 3 页
字号:
#include <stdio.h>#include "term.h"#include <stdlib.h>//#define debug_flag/*to handle all transfers between main text and text celsto build text cels from subsets and add lines as neededeither scrollable text cels or multiple fixed celssets of cels (such as fixed cels) are listed in categorytext in fixed cel sets may include anchors, which split this list*/term::~term(){//   free( cursors );   delete cursors;}#include <strings.h> // bzeroterm::term(){   exiting = false;   shiftlock = false;   mousekeys = false;   last = next = repl = NULL;   area[ 0 ] = this; // remove this?//   cursors = ( u_int* )malloc( 5 * sizeof( int ) );   cursors = new u_int[ 5 ];   bzero( cursors, 5 * sizeof( int ) );   cursor_total = 1;//   int cursor = 0; // _here   xhere = ( u_int )( s -> top ); // here, note::s//   row = 0; pcol = col = 0;   rows = 1;//   orig = 0;}void term::del_cursor( u_int which ){   cursors[ 5 * which ] = 0xFFFFFFFF;   int it = cursor_total - 1;   for(; it > 0 && cursors[ 5 * it ] != 0xFFFFFFFF; it-- );   if( ++it < cursor_total )   {      cursor_total = it;//      u_int* temp = ( u_int* )malloc( 5 * cursor_total );      u_int* temp = new u_int[ 5 * cursor_total ];      memcpy( temp, cursors, it * 5 * sizeof( int ) );//      free( cursors );      delete cursors;      cursors = temp;   }}u_int term::add_cursor(){   int it = 0;   for(; it < cursor_total && cursors[ 5 * it ] != 0xFFFFFFFF; it++ );   if( it == cursor_total )   {//      u_int* temp = ( u_int* )malloc( 5 * ++cursor_total * sizeof( int ) );      u_int* temp = new u_int[ 5 * ++cursor_total ];      memcpy( temp, cursors, it * 5 * sizeof( int ) );//      free( cursors );      delete cursors;      cursors = temp;   }   cursors[ 5 * it ] = 0;   cursors[ 5 * it + 1 ] = 0;   cursors[ 5 * it + 2 ] = 0;   cursors[ 5 * it + 3 ] = 0;   cursors[ 5 * it + 4 ] = ( u_int )( s -> top );   return it;}void term::for_each_cursor_below( u_int row, void(term::* x)( u_int ) ){   int it = 0;   for(; it < cursor_total; it++ )   {      if( cursors[ 5 * it ] == 0xFFFFFFFF ) continue;      if( cursors[ 5 * it + 1 ] <= row ) continue; // below      ( this ->*x )( it );   }}void term::for_each_cursor_right( u_int row, u_int col,   void(term::* x)( u_int, u_int ) ){   int it = 0;   for(; it < cursor_total; it++ )   {      if( cursors[ 5 * it ] == 0xFFFFFFFF ) continue;      if( cursors[ 5 * it + 1 ] != row ) continue; // same row      if( cursors[ 5 * it + 2 ] <= col ) continue; // to right      ( this ->*x )( it, col );   }}void term::for_each_cursor_here( u_int row, u_int data,   void(term::* x)( u_int, u_int ) ){   int it = 0;   for(; it < cursor_total; it++ )   {      if( cursors[ 5 * it ] == 0xFFFFFFFF ) continue;      if( cursors[ 5 * it + 1 ] != row ) continue; // same row      ( this ->*x )( it, data );   }}void term::for_each_cursor( void(term::* x)( u_int ) ){   int it = 0;   for(; it < cursor_total; it++ )   {      if( cursors[ 5 * it ] == 0xFFFFFFFF ) continue;      ( this ->*x )( it );   }}void term::set_each_line( line* x ){   int it = 0;   for(; it < cursor_total; it++ )   {      if( cursors[ 5 * it ] == 0xFFFFFFFF ) continue;      cursors[ 5 * it + 4 ] = ( u_int )x;   }}void term::home_cursor( u_int cursor ){   _orig = _row = 0;   _col = _pcol = 0;   _here = ( u_int )( s -> top );}void term::dec_orig( u_int cursor ){   _orig--;}void term::dec_row( u_int cursor ){   _row--;}void term::inc_row( u_int cursor ){   _row++;}void term::dec_col( u_int cursor, u_int col ){   _col--;}void term::inc_col( u_int cursor, u_int col ){   _col++;}void term::cursor_lbs( u_int cursor, u_int col ) // line backspace{   _col += col;   _row--;   _here = ( u_int )( __here -> last );}void term::cursor_cr( u_int cursor, u_int col ){   _col -= col;   _row++;   _here = ( u_int )( __here -> next );}/*term::term( void* h ){   area[ 0 ] = new text( h );}*/void nul() {}	/* 00: ^`, ^break */void soh() {}void stx() {}void etx() {}void eot() {}void enq() {}void ack() {}void bel() {}void term::ht( u_int cursor ){}void lf() {}	/* 0A */void vt() {}void ff() {}/*   clear();   int it = xrow;   for(; it > xorig; it-- )   {      xhere = ( u_int )( x_here -> last );   }   write( x_here -> text, 0, it++ - xorig );   for(; it < xorig + note::rows && it < rows; it++ )   {      xhere = ( u_int )( x_here -> next );      write( x_here -> text, 0, it - xorig );   }   for( it--; it > xrow; it-- ) // start on last visible line   {      xhere = ( u_int )( x_here -> last );   }   repos( xcol, xrow - xorig );*/void term::redraw(){   clear();   int it = xrow;   for(; it > xorig; it-- )   {      xhere = ( u_int )( x_here -> last );   }   for(;; it++, xhere = ( u_int )( x_here -> next ) )   {      write( x_here -> text, 0, it - xorig );      if( it == rows - 1 ) break;      if( it == xorig + note::rows - 1 ) break;   }   for(; it > xrow; it-- )   {      xhere = ( u_int )( x_here -> last );   }   repos( xcol, xrow - xorig );#ifdef debug_flag   debug();#endif // debug}void term::debug(){      printf( "t %08X h %08X b %08X rows %d row %d\r\n"      , ( u_int )( s -> top ), cursors[ 4 ], ( u_int )( s -> bot )      , rows, xrow );      line* l = s -> top;      for(; l != NULL; l = l -> next )      {	 printf( "l %08X n %08X"	 , ( u_int )( l -> last ), ( u_int )( l -> next ) );	 if( l -> id_mask == ID_LINE_S )	 {	    script* s = ( ( line_s* )l ) -> scr;	    printf( " t %08X l %08X b %08X n %08X\r\n"	    , ( u_int )( s -> top ), ( u_int )( s -> top -> last )	    , ( u_int )( s -> bot ), ( u_int )( s -> bot -> next ) );	 }	 else printf( "\r\n" );      }}extern FILE* _file;// update each here for cursors within this contextvoid term::expand( u_int cursor ){   line_s* lines = ( line_s* )__here;   if( __here -> id_mask == ID_LINE_S )   {      if( lines -> next == lines -> scr -> top )	 return; // already expanded   }   else // not ID_LINE_S   {      lines = new line_s( __here ); // here is no longer here, has moved      if( __here -> last != NULL )      {	 __here -> last -> next = lines;	 if( __here -> last -> id_mask == ID_LINE_S	 && ( ( line_s* )( __here -> last ) ) -> scr -> top == __here )	   ( ( line_s* )( __here -> last ) ) -> scr -> top = lines;      } // else      if( _row == 0 ) s -> top = lines;// if it has a name, loop through parent contexts//      if( strlen( lines -> text ) == 0 )      {	 lines -> scr -> id_mask = ID_SCRIPT_DIR;	 atom* _a = lines -> parent;	 if( _a == NULL )	 {	 }_file = fopen( "atom.log", "a" );fprintf( _file, "1\n" );fflush( _file );	 lines -> scr -> load( "/root/hier" );fprintf( _file, "4\n" );fflush( _file );	 char* cx; // strange bug, do investigate further//	 if( lines == s -> top || strlen( lines -> last -> text ) != 23 ){	 cx = lines -> ptrtocx( lines -> scr );}//	 else { cx = new char[ 1 ]; cx[ 0 ] = '\0'; }	 lines -> clear();//	 lines -> ins( 0, "" );//	 cx[ 40 ] = '\0';	 lines -> ins( 0, cx );	 delete[] cx;fprintf( _file, "5\n" );fflush( _file );fclose( _file );      }   }   if( _row > 0 )      update_to_top( cursor, lines, __here, lines -> scr -> bot      , __here -> last, _row - 1 );   if( __here == s -> bot )      s -> bot = lines -> scr -> bot;   _here = ( u_int )lines;   if( _row == 0 ) s -> top = __here;   lines -> scr -> top -> last = __here;   lines -> scr -> bot -> next = __here -> next;   if( __here -> next != NULL )   {      __here -> next -> last = lines -> scr -> bot;   }   __here -> next = lines -> scr -> top;   _here = ( u_int )( lines -> scr -> bot );   for_each_cursor_below( _row, &term::inc_row );   int count = 1;   for(; __here != lines -> scr -> top;      _here = ( u_int )( __here -> last ), ++count )      for_each_cursor_below( _row, &term::inc_row );   rows += count;   _row++;   _pcol = _col = 0;   repos( 0, xrow - xorig );   if( _row - _orig == note::rows ) _orig++;   if( _row > xorig + note::rows || _row + count <= xorig ) return;   redraw();}//#include <stdio.h>/*{}   _here = ( u_int )( s -> ins( __here ) ); // prepare to update each _here*/void term::cr( u_int cursor ){   u_int x = _row;   line* brand = ( ( script* )( __here -> parent ) ) -> ins( __here );   line* top = find_top( cursor, x );   if( top != NULL )      update_to_top( cursor, brand, __here, brand, top, x );   if( __here -> id_mask == ID_LINE_S )   {      _col = __here -> length;      if( brand -> next == ( ( line_s* )__here ) -> scr -> top )	 ( ( line_s* )__here ) -> scr -> top = brand;   }   if( __here == s -> bot ) // move this to script::ins()      s -> bot = brand;   _here = ( u_int )brand;   __here -> split( _col );/*   if( __here -> next != NULL )   {      if( __here -> next -> id_mask == ID_LINE_S      && ( ( line_s* )( __here -> next ) ) -> scr -> top -> last != NULL )	 ( ( line_s* )( __here -> next ) ) -> scr -> top -> last = __here;   }*/   rows++;   for_each_cursor_below( _row, &term::inc_row );   for_each_cursor_right( _row, _col, &term::cursor_cr );   _row++;   _pcol = _col = 0;   repos( 0, xrow - xorig );   if( _row - _orig == note::rows ) _orig++;   if( _row > xorig + note::rows || _row < xorig ) return;   redraw();}void so() {}void si() {}void dle() {}void xon() {}void dc2() {}void xoff() {}void dc4() {}	/* 14 */void nak() {}void syn() {}void etb() {}void can() {}void em() {}void sub() {}void fs() {}	/* 1C: prtsc */void gs() {}void rs() {}void us() {}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -