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

📄 movement.c

📁 一个开源著名的TDE编辑器源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
 * jmh 991123: return ERROR if can't go any further; *             skip ccol == end_col test; *             don't bother showing the ruler after the sync. * jmh 030302: recognise the stream version. */int  move_right( TDE_WIN *window ){register TDE_WIN *win;text_ptr p;int  len;int  rc = OK;int  moved = FALSE;   win = window;   if (g_status.command == StreamCharRight  &&  !mode.draw) {      if (g_status.copied && win->file_info == g_status.current_file) {         p   = g_status.line_buff;         len = g_status.line_buff_len;      } else {         p   = win->ll->line;         len = win->ll->len;      }      len = find_end( p, len, win->file_info->inflate_tabs,                              win->file_info->ptab_size );      if (win->rcol >= len) {         undo_move( win, 0 );         rc = prepare_move_down( win );         show_ruler_char( win );         check_virtual_col( win, 0, win->start_col );         moved = TRUE;      }   }   if (!moved) {      if (win->rcol < MAX_LINE_LENGTH - 1) {         if (mode.cursor_cross)            win->file_info->dirty = LOCAL;         if (mode.draw && win->ll->len != EOF)            set_horz_g_char( win, G_RT );         undo_move( win, CharLeft );         if (win->ccol < win->end_col) {            show_ruler_char( win );            ++win->ccol;         } else { /* (win->ccol == win->end_col) */            ++win->bcol;            win->file_info->dirty = LOCAL | RULER;         }         ++win->rcol;      } else         rc = ERROR;   }   cursor_sync( win );   return( rc );}/* * Name:    pan_left * Purpose: To pan the screen left one character * Date:    January 5, 1992 * Passed:  window:  pointer to current window * * jmh 991123: return ERROR if can't pan any further. */int  pan_left( TDE_WIN *window ){int  rc = OK;   if (window->bcol > 0 ) {      undo_move( window, PanRight );      --window->bcol;      --window->rcol;      window->file_info->dirty = LOCAL | RULER;   } else      rc = ERROR;   cursor_sync( window );   return( rc );}/* * Name:    pan_right * Purpose: To pan the screen right one character * Date:    January 5, 1992 * Passed:  window:  pointer to current window * * jmh 991123: return ERROR if can't pan any further. */int  pan_right( TDE_WIN *window ){int  rc = OK;   if (window->bcol < MAX_LINE_LENGTH -                        (window->end_col - window->start_col + 1)) {      undo_move( window, PanLeft );      ++window->rcol;      ++window->bcol;      window->file_info->dirty = LOCAL | RULER;   } else      rc = ERROR;   cursor_sync( window );   return( rc );}/* * Name:    word_left * Purpose: To move the cursor left one word * Date:    June 5, 1991 * Passed:  window:  pointer to current window * Notes:   Words are considered strings of letters, numbers and underscores, *          which must be separated by other characters. * * jmh 991123: allow movement off EOF. * jmh 021012: recognise WordWrap as a special case (for paragraph formatting). */int  word_left( TDE_WIN *window ){text_ptr p;             /* text pointer */int  len;               /* length of current line */int  rc;int  tabs;int  rcol;register int r1;TDE_WIN w;int  (*space)( int );   /* Function to determine what a word is */int  (*spc)( int );     /* Function to determine what is a space */int  end;               /* End of word? */int  eol;               /* On or beyond EOL? */   if (window->rline > 0) {      if (un_copy_line( window->ll, window, TRUE, TRUE ) == ERROR)         return( ERROR );      switch (g_status.command) {         default:         case WordLeft:      space = myiswhitespc;    break;         case WordEndLeft:   space = myisnotwhitespc; break;         case WordWrap:         case StringLeft:    space = bj_isspc;        break;         case StringEndLeft: space = bj_isnotspc;      }      end = (g_status.command == WordEndLeft  ||             g_status.command == StringEndLeft);      spc = (g_status.command == WordLeft || g_status.command == WordEndLeft)             ? myiswhitespc : bj_isspc;      rc = OK;      dup_window_info( &w, window );      rcol = w.rcol;      p    = w.ll->line;      len  = w.ll->len;      tabs = (window->file_info->inflate_tabs)             ? window->file_info->ptab_size : 0;      r1 =  tabs ? entab_adjust_rcol( p, len, rcol, tabs ) : rcol;      if (r1 >= len) {         eol = (r1 > len  &&  end) ? ERROR : TRUE;         r1  = len - 1;      } else         eol = FALSE;      if (r1 > 0)         p += r1;      if (!end && r1 >= 0 && !space(*p) && (eol || (r1 > 0 && !space(*(p-1))))){         /* do nothing */      } else if (eol == ERROR && r1 >= 0 && space( *p )) {         /* do nothing */      } else {         /*          * if we are on the first letter of a word, get off.          */         if (end && r1 > 0 && !eol && spc( *p ) && !spc( *(p-1) )) {            --r1;            --p;         }         for (; r1 >= 0 && !spc( *p ); r1--, p--);         /*          * go to the previous line if word begins at 1st col in line.          */         if (r1 < 0) {            if (dec_line( &w, FALSE )) {               p  = w.ll->line;               r1 = w.ll->len - 1;               if (r1 > 0)                  p += r1;            } else               rc = ERROR;         }         /*          * skip all blanks until we get to a previous word          */         while (rc == OK  &&  (p == NULL  ||  spc( *p ))) {            for (; r1 >= 0 && spc( *p ); r1--, p--);            if (r1 < 0) {               if (dec_line( &w, FALSE )) {                  p  = w.ll->line;                  r1 = w.ll->len - 1;                  if (r1 > 0)                     p += r1;               } else                  rc = ERROR;            } else               break;         }      }      if (rc == OK) {         if (g_status.command != WordWrap)            undo_move( window, (g_status.command_count == 0) ? 0 : WordRight );         /*          * now, find the beginning of the word.          */         for (; r1 >= 0 && !space( *p ); r1--, p--);         ++r1;         w.rcol =  tabs ? detab_adjust_rcol( w.ll->line, r1, tabs ) : r1;         move_display( window, &w );      }   } else      rc = ERROR;   if (g_status.command != WordWrap)      cursor_sync( window );   return( rc );}/* * Name:    word_right * Purpose: To move the cursor right one word * Date:    June 5, 1991 * Passed:  window:  pointer to current window * Notes:   Words are considered strings of letters, numbers and underscores, *           which must be separated by other characters. * * jmh 991123: allow movement off TOF. * jmh 021012: recognise WordWrap as a special case (for paragraph formatting). */int  word_right( TDE_WIN *window ){int  len;               /* length of current line */text_ptr p;             /* text pointer */int  rc;int  tabs;int  rcol;register int r1;TDE_WIN w;int  (*space)( int );   /* Function to determine what a word is */int  end;               /* Searching for end of word? */int  tab_size;   if (window->ll->next != NULL) {      if (un_copy_line( window->ll, window, TRUE, TRUE ) == ERROR)         return( ERROR );      rc = OK;      dup_window_info( &w, window );      r1  = rcol = window->rcol;      p   = w.ll->line;      len = w.ll->len;      tabs = window->file_info->inflate_tabs;      tab_size = window->file_info->ptab_size;      r1   =  tabs ? entab_adjust_rcol( p, len, rcol, tab_size ) : rcol;      end   = (g_status.command == WordEndRight ||               g_status.command == StringEndRight);      space = (g_status.command == WordRight ||               g_status.command == WordEndRight) ? myiswhitespc : bj_isspc;      /*       * if rcol is past EOL, move it to EOL       */      r1 =  r1 > len ? len : r1;      if (r1 > 0)         p += r1;      /*       * if cursor is on a word, find end of word.       */      if (end  &&  r1 < len  &&  !space( *p )) {         /* do nothing */      } else {         for (; r1 < len && !space( *p ); r1++, p++);         /*          * go to the next line if word ends at eol.          */         if (r1 == len) {            if (inc_line( &w, FALSE )) {               p   = w.ll->line;               len = w.ll->len;               r1  = 0;            } else               rc = ERROR;         }         /*          * now, go forward thru the file looking for the first letter of word.          */         while (rc == OK  &&  (p == NULL  ||  space( *p ))) {            for (; r1 < len && space( *p ); r1++, p++);            if (r1 == len) {               if (inc_line( &w, FALSE )) {                  p   = w.ll->line;                  len = w.ll->len;                  r1  = 0;               } else                  rc = ERROR;            } else               break;         }      }      if (rc == OK) {         if (g_status.command != WordWrap)            undo_move( window, (g_status.command_count == 0) ? 0 : WordLeft );         /*          * now find the end of the word.          */         if (end)            for (; r1 < len && !space( *p ); r1++, p++);         w.rcol =  tabs ? detab_adjust_rcol( w.ll->line, r1, tab_size ) : r1;         move_display( window, &w );      }   } else      rc = ERROR;   if (g_status.command != WordWrap)      cursor_sync( window );   return( rc );}/* * Name:     find_dirty_line * Purpose:  To move the cursor to the next/previous dirty line, if it exists * Date:     April 1, 1993 * Modified: August 12, 1997, Jason Hood - reposition for real tabs * Passed:   window:  pointer to current window * * jmh 980824: skip groups of dirty lines. * jmh 991124: combined next and previous dirty lines into one routine. */int  find_dirty_line( TDE_WIN *window ){int  rc;TDE_WIN w;int  (*new_line)( TDE_WIN *, int );   if (un_copy_line( window->ll, window, TRUE, TRUE ) == ERROR)      return( ERROR );   dup_window_info( &w, window );   rc = OK;   new_line = (g_status.command == PrevDirtyLine) ? dec_line : inc_line;   while (w.ll->type & DIRTY)      new_line( &w, TRUE );   while (!(w.ll->type & DIRTY)) {      if (!new_line( &w, FALSE )) {         rc = ERROR;         break;      }   }   if (rc == OK) {      undo_move( window, 0 );      set_marker( window );             /* remember previous position */      move_display( window, &w );   } else      error( WARNING, window->bottom_line, utils16 );   cursor_sync( window );   return( rc );}/* * Name:    find_browse_line * Purpose: move the cursor to the file/line given in another window * Author:  Jason Hood * Date:    November 16, 2003 * Passed:  window:  pointer to current window * Notes:   if the current window is output or results, either function will *           make it the current browse window, using the current line. *          if there is no browse window, use the current file if it's scratch. *          if the end/top of file is reached, wrap. */int  find_browse_line( TDE_WIN *window ){int  current;char name[PATH_MAX];char cwd[PATH_MAX];long rline = 0;int  rcol = -1;long stop;TDE_WIN w;TDE_WIN *win;file_infos *fp;int  rc;   if (un_copy_line( window->ll, window, TRUE, TRUE ) == ERROR)      return( ERROR );   if (window->file_info->file_name[0] == '\0' &&       (window->file_info->file_name[1] == OUTPUT ||        window->file_info->file_name[1] == RESULTS)) {      browser_window = window;      fp = window->file_info;      current = TRUE;   } else      current = FALSE;   if (browser_window == NULL) {      /*       * try and find a browser file after the current       */      fp = window->file_info->next;      while (fp != NULL  &&  !(fp->file_name[0] == '\0' &&             (fp->file_name[1] == OUTPUT || fp->file_name[1] == RESULTS)))         fp = fp->next;      if (fp == NULL) {         /*          * try and find a browser file before the current          */         fp = window->file_info->prev;         while (fp != NULL  &&  !(fp->file_name[0] == '\0' &&                (fp->file_name[1] == OUTPUT || fp->file_name[1] == RESULTS)))            fp = fp->prev;      }      if (fp == NULL) {         if (window->file_info->scratch) {            browser_window = window;            fp = window->file_info;         } else {            /*             * no browser window             */            error( WARNING, g_display.end_line, utils18a );            return( ERROR );         }      } else         browser_window = find_file_window( fp );      current = (g_status.command == NextBrowse);   } else      fp = browser_window->file_info;   /*    * Set the current directory to that of the browser, since it uses    * relative paths.    */   get_current_directory( cwd );   set_current_directory( fp->backup_fname );

⌨️ 快捷键说明

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