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

📄 diff.c

📁 一个开源著名的TDE编辑器源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
   if (node1->len != EOF  &&  node2->len != EOF) {      diff1 = node1->line;      diff2 = node2->line;      rcol1 = initial_rcol1;      rcol2 = initial_rcol2;      len1  = node1->len;      len2  = node2->len;      assert( rcol1 >= 0 );      assert( rcol1 < MAX_LINE_LENGTH );      assert( rcol2 >= 0 );      assert( rcol2 < MAX_LINE_LENGTH );      assert( len1 >= 0 );      assert( len1 < MAX_LINE_LENGTH );      assert( len2 >= 0 );      assert( len2 < MAX_LINE_LENGTH );      /*       * if cursors are past EOL, move them back to EOL.       */      len = find_end( diff1, len1, tabs1, tab_size1 );      if (rcol1 > len)         rcol1 = len;      len = find_end( diff2, len2, tabs2, tab_size2 );      if (rcol2 > len)         rcol2 = len;      /*       * if skip leading space, make sure our cursors start on first non-space.       */      if (diff.leading) {         leading1 = skip_leading_space( diff1, len1, tabs1, tab_size1 );         leading2 = skip_leading_space( diff2, len2, tabs2, tab_size2 );         if (rcol1 < leading1)            rcol1 = leading1;         if (rcol2 < leading2)            rcol2 = leading2;      }      /*       * we now have a valid rcol for the diff start, we may need to adjust       *   for tabs, though.       */      assert( rcol1 >= 0 );      assert( rcol1 < MAX_LINE_LENGTH );      assert( rcol2 >= 0 );      assert( rcol2 < MAX_LINE_LENGTH );      show_search_message( DIFFING );      while ((node1->len != EOF  ||  node2->len != EOF)  &&                         !g_status.control_break) {         /*          * diff each character in the diff lines until we reach EOL          */         while (TRUE) {            ADJUST_TAB1;            ADJUST_TAB2;            /*             * if one of the node pointers has come to EOL, move to next             *   diff line.             */            if (diff.ignore_eol) {               if (r1 >= len1) {                  node1 = skip_eol( &win1, &r1, &rcol1, tabs1, tab_size1 );                  len1  = node1->len;                  diff1 = node1->line;               }               if (r2 >= len2) {                  node2 = skip_eol( &win2, &r2, &rcol2, tabs2, tab_size2 );                  len2  = node2->len;                  diff2 = node2->line;               }            }            /*             * look at each character in each diff window             */            GET_C1;            GET_C2;            /*             * skip spaces, if needed             */            if (diff.all_space) {               while (c1 == ' '  &&  r1 < len1) {                  ++rcol1;                  ADJUST_TAB1;                  GET_C1;               }               while (c2 == ' '  &&  r2 < len2) {                  ++rcol2;                  ADJUST_TAB2;                  GET_C2;               }               if (diff.ignore_eol) {                  if (r1 >= len1) {                     node1 = skip_eol( &win1, &r1, &rcol1, tabs1, tab_size1 );                     len1  = node1->len;                     diff1 = node1->line;                     GET_C1;                  }                  if (r2 >= len2) {                     node2 = skip_eol( &win2, &r2, &rcol2, tabs2, tab_size2 );                     len2  = node2->len;                     diff2 = node2->line;                     GET_C2;                  }               }            }            if (r1 >= len1  ||  r2 >= len2)               break;            /*             * convert the characters to lower case, if needed.             */            if (mode.search_case == IGNORE) {               c1 = (char)bj_tolower( c1 );               c2 = (char)bj_tolower( c2 );            }            if (c1 != c2)               break;            ++rcol1;            ++rcol2;         }         /*          * if we haven't come to the end of a file buffer, check the last          *   characters.  see if pointers are at EOL.          */         if (node1->len != EOF  ||  node2->len != EOF) {            if (r1 < len1  ||  node1->len == EOF  ||                r2 < len2  ||  node2->len == EOF) {               undo_move( diff.w1, 0 );               undo_move( diff.w2, 0 );               set_marker( diff.w1 );               set_marker( diff.w2 );               win1.rcol = rcol1;               move_display( diff.w1, &win1 );               show_diff_window( diff.w1 );               win2.rcol = rcol2;               move_display( diff.w2, &win2 );               show_diff_window( diff.w2 );               show_search_message( CLR_SEARCH );               return( OK );            } else {               node1 = skip_eol( &win1, &r1, &rcol1, tabs1, tab_size1 );               len1  = node1->len;               diff1 = node1->line;               node2 = skip_eol( &win2, &r2, &rcol2, tabs2, tab_size2 );               len2  = node2->len;               diff2 = node2->line;            }         }         assert( rcol1 >= 0 );         assert( rcol1 < MAX_LINE_LENGTH );         assert( rcol2 >= 0 );         assert( rcol2 < MAX_LINE_LENGTH );         assert( r1 >= 0 );         assert( r1 < MAX_LINE_LENGTH );         assert( r2 >= 0 );         assert( r2 < MAX_LINE_LENGTH );         assert( r1 <= rcol1 );         assert( r2 <= rcol2 );         if (node1->len == EOF)            assert( len1 == EOF );         else {            assert( len1 >= 0 );            assert( len1 < MAX_LINE_LENGTH );         }         if (node2->len == EOF)            assert( len2 == EOF );         else {            assert( len2 >= 0 );            assert( len2 < MAX_LINE_LENGTH );         }      }      error( INFO, bottom, diff_prompt4 );      show_search_message( CLR_SEARCH );   }   return( ERROR );}/* * Name:    skip_leading_space * Purpose: put the diff on the first non-blank character * Date:    October 31, 1992 * Passed:  s:  the string to search *          len: length of string *          tabs: should tabs be skipped? *          tab_size: size of tabs * Returns: the first non-blank column */int  skip_leading_space( text_ptr s, int len, int tabs, int tab_size ){register int count = 0;text_ptr ll = s;   assert( len >= 0 );   assert( len < MAX_LINE_LENGTH );   if (s != NULL) {      if (tabs) {         while (len > 0  &&  (*s == ' ' || *s == '\t')) {            ++count;            ++s;            --len;         }         count = detab_adjust_rcol( ll, count, tab_size );      } else {         while (len > 0  &&  *s == ' ') {           ++count;           ++s;           --len;         }      }   }   if (len == 0)      count = 0;   return( count );}/* * Name:    skip_eol * Purpose: move the diff to the next line * Date:    October 31, 1992 * Passed:  win:         pointer to current window (node, line number, offset) *          r:           tab adjusted real col *          rcol:        real real col *          tabs:        do tabs count? *          tab_size:    size of tabs * Returns: next non-blank node */line_list_ptr skip_eol( TDE_WIN *win, int *r, int *rcol,                        int tabs, int tab_size ){   *r = *rcol = 0;   if (inc_line( win, TRUE )) {      if (diff.blank_lines)         while (is_line_blank( win->ll->line, win->ll->len, tabs )  &&                inc_line( win, TRUE )) ;      if (win->ll->len != EOF) {         if (diff.leading)            *rcol = skip_leading_space( win->ll->line, win->ll->len,                                        tabs, tab_size );         else            *rcol = 0;         *r = *rcol;         if (tabs)            *r = entab_adjust_rcol( win->ll->line, win->ll->len, *rcol,                                    tab_size );      }   }   return( win->ll );}/* * Name:    show_diff_window * Purpose: update the contents of a diff window * Date:    October 31, 1992 * Passed:  win:  pointer to window */void show_diff_window( TDE_WIN *win ){   if (win->file_info->dirty & LOCAL)      display_current_window( win );   show_line_col( win );   if (win->file_info->dirty & RULER)      show_ruler( win );   show_ruler_pointer( win );   win->file_info->dirty = FALSE;}

⌨️ 快捷键说明

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