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

📄 hwind.c

📁 一个开源著名的TDE编辑器源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
 * Date:    November 20, 1999 * Notes:   use the diagnostic space */void show_undo_mode( void ){   show_search_message( UNDO_GROUP + mode.undo_group );   g_status.wrapped = TRUE;}/* * Name:    show_undo_move * Purpose: indicate whether movement is undone * Author:  Jason Hood * Date:    May 20, 2001 * Notes:   use the diagnostic space */void show_undo_move( void ){   show_search_message( UNDO_MOVE + mode.undo_move );   g_status.wrapped = TRUE;}/* * Name:    show_recording * Purpose: indicate a macro is being recorded * Author:  Jason Hood * Date:    November 29, 1998 * Notes:   Overwrites the tabs, indent, ingore and sync displays. */void show_recording( void ){   s_output( main15, g_display.mode_line, 22, Color( Special ) );   show_avail_strokes( 0 );}/* * Name:    show_cwd * Purpose: display the cwd at the top of the screen * Author:  Jason Hood * Date:    February 26, 2003 */void show_cwd( void ){char cwd[PATH_MAX];   if (get_current_directory( cwd ) == ERROR)      strcpy( cwd, "." );   s_output( reduce_string( cwd, cwd, g_display.ncols, MIDDLE ),             0, 0, Color( CWD ) );   eol_clear( strlen( cwd ), 0, Color( CWD ) );}/* * Name:    my_scroll_down * Purpose: display a portion of a window * Date:    June 5, 1991 * Passed:  window:  pointer to current window * Notes:   Using the bios scroll functions causes a slightly noticable *            "flicker", even on fast VGA monitors.  This is caused by changing *            the high-lited cursor line to text color then calling the bios *            function to scroll.  Then, the current line must then be *            hilited. *          This function assumes that win->cline is the current line. * * jmh 030329: don't blank out lines beyond EOF, since they're already blank; *             use the normal syntax color, when appropriate. */void my_scroll_down( TDE_WIN *window ){int  i;TDE_WIN w;              /* scratch window struct for dirty work */   if (!window->visible  ||  !g_status.screen_display)      return;   dup_window_info( &w, window );   if (w.ll->next == NULL)      show_eof( &w );   else {      show_curl_line( window );      for (i = w.bottom_line - w.cline; i > 0; i--) {         ++w.cline;         ++w.rline;         w.ll = w.ll->next;         if (w.ll->len != EOF)            update_line( &w );         else {            show_eof( &w );            break;         }      }   }   if (w.ll->len == EOF  &&  w.cline != w.bottom_line) {      ++w.cline;      window_eol_clear( &w, (w.syntax) ? syntax_color[0] : Color( Text ) );   }}/* * Name:    eol_clear * Purpose: To clear the line from col to max columns * Date:    June 5, 1991 * Passed:  col:   column to begin clear *          line:  line to clear *          attr:  color to clear */void eol_clear( int col, int line, int attr ){   c_repeat( ' ', g_display.ncols, col, line, attr );}/* * Name:    window_eol_clear * Purpose: To clear the line from start_col to end_col * Date:    June 5, 1991 * Passed:  window:  pointer to window *          attr:  color to clear */void window_eol_clear( TDE_WIN *window, int attr ){int  col;   if (!g_status.screen_display)      return;   col = window->left;   c_repeat( ' ', window->end_col - col + 1, col, window->cline, attr );}/* * Name:    n_output * Purpose: display a number * Author:  Jason Hood * Date:    November 19, 2003 * Passed:  num:  number to display *          wid:  width to display it *          col:  column *          line: line number *          attr: color * Notes:   if wid is 0, the number will simply be displayed at col; if wid *           is positive, it will be displayed at col and padded with spaces *           to fit wid; if negative, it will be right aligned.  If the number *           is too big to fit, the most significant digits are dropped. *          assumes num is positive. */void n_output( long num, int wid, int col, int line, int attr ){char buf[16];int  len;int  spc;   my_ltoa( num, buf, 10 );   if (wid) {      len = numlen( num );      spc = col;      if (wid < 0) {         wid = -wid;         if (wid - len > 0)            col += wid - len;      } else         spc += len;      if (len >= wid)         buf[wid] = '\0';      else         c_repeat( ' ', wid - len, spc, line, attr );   }   s_output( buf, line, col, attr );}/* * Name:    combine_strings * Purpose: stick 3 strings together * Date:    June 5, 1991 * Passed:  buff:    buffer to hold concatenation of 3 strings *          s1:  pointer to string 1 *          s2:  pointer to string 2 *          s3:  pointer to string 3 * * jmh 021031: test for s3 being NULL (instead of requiring ""). * jmh 021106: if buff is line_out, truncate s2 such that s1+s2+s3 will fit *              on the screen. */void combine_strings( char *buff, const char *s1, const char *s2,                                  const char *s3 ){char temp[MAX_COLS];int  len;   if (buff == line_out) {      len = g_display.ncols - 1 - strlen( s1 );      if (s3)         len -= strlen( s3 );      s2 = reduce_string( temp, s2, len, MIDDLE );   }#if defined( __DJGPP__ ) || defined( __TURBOC__ )   if (s3)      strcpy( stpcpy( stpcpy( buff, s1 ), s2 ), s3 );   else      strcpy( stpcpy( buff, s1 ), s2 );#else   strcpy( buff, s1 );   strcat( buff, s2 );   if (s3)      strcat( buff, s3 );#endif}/* * Name:    reduce_string * Purpose: reduce the length of a string * Author:  Jason Hood * Date:    November 5, 2002 * Passed:  buf:  place to store the reduced string *          str:  the string to reduce *          wid:  the maximum length of the string *          flag: how the string should be reduced * Returns: buf * Notes:   flag can be BEGIN, MIDDLE or END, where that portion of the string *           is replaced with "..." (ie. flag indicates the bit removed, not *           the bit remaining). eg: "a long string" reduced to eight chars: *           BEGIN:  "...tring" *           MIDDLE: "a ...ing" *           END:    "a lon..." *          buf is assumed to be at least wid+1 characters. */char *reduce_string( char *buf, const char *str, int wid, int flag ){int  len;int  wid2;   len = strlen( str );   if (len <= wid)      memcpy( buf, str, len + 1 );   else {      wid -= 3;      if (flag == BEGIN)         join_strings( buf, "...", str + len - wid );      else if (flag == END) {         memcpy( buf, str, wid );         strcpy( buf + wid, "..." );      } else /* flag == MIDDLE */ {         wid2 = wid / 2;         memcpy( buf, str, wid2 );         join_strings( buf + wid2, "...", str + len - (wid2 + (wid & 1)) );      }   }   return( buf );}/* * Name:    make_ruler * Purpose: make ruler with tabs, tens, margins, etc... * Date:    June 5, 1991 * * jmh 991110: made the ruler global; *             use the actual tens digit, not div 10. */void make_ruler( void ){register char *p;char *end;char tens;   memset( ruler_line, RULER_FILL, MAX_LINE_LENGTH+MAX_COLS );   end = ruler_line + MAX_LINE_LENGTH+MAX_COLS;   *end = '\0';   /*    * indicate the "fives" column    */   for (p = ruler_line + 4; p < end; p += 10)      *p = RULER_TICK;   /*    * put a tens digit in the tens column    */   tens = '1';   for (p = ruler_line + 9; p < end; p += 10) {      *p = tens;      if (++tens > '9')         tens = '0';   }   ruler_line[mode.parg_margin]  = PGR_CHAR;   ruler_line[mode.left_margin]  = (char)(unsigned char)LM_CHAR;   ruler_line[mode.right_margin] = (mode.right_justify) ? RM_CHAR_JUS :                                                          RM_CHAR_RAG;}/* * Name:    show_ruler * Purpose: show ruler with tens, margins, etc... * Date:    June 5, 1991 * Passed:  window:  pointer to current window * * jmh 991110: display as an offset into the global ruler. */void show_ruler( TDE_WIN *window ){register TDE_WIN *win;char *ruler;char save;int  len;   win = window;   if (win->ruler && win->visible) {      ruler = ruler_line + win->bcol;      len = win->end_col - win->start_col + 1;      save = ruler[len];      ruler[len] = '\0';      s_output( ruler, win->top+1, win->start_col, Color( Ruler ) );      ruler[len] = save;      if (mode.line_numbers)         c_repeat( ' ', win->file_info->len_len, win->left, win->top+1,                   Color( Ruler ) );      refresh( );   }}/* * Name:    show_ruler_char * Purpose: show ruler character under ruler pointer * Date:    June 5, 1991 * Passed:  window:  pointer to current window */void show_ruler_char( TDE_WIN *window ){register TDE_WIN *win;   win = window;   if (win->ruler && win->visible) {      c_output( ruler_line[win->rcol], win->ccol, win->top+1, Color( Ruler ) );      refresh( );   }}/* * Name:    show_ruler_pointer * Purpose: show ruler pointer * Date:    June 5, 1991 * Passed:  window:  pointer to current window * * jmh 050721: cursor cross assumes show_ruler_char is called first to remove *              the old one before calling this to show the new. */void show_ruler_pointer( TDE_WIN *window ){   if (window->ruler && window->visible) {      c_output( RULER_PTR, window->ccol, window->top+1, Color( Pointer ) );      refresh( );   }}/* * Name:    show_all_rulers * Purpose: make and show all rulers in all visible windows * Date:    June 5, 1991 */void show_all_rulers( void ){register TDE_WIN *wp;   make_ruler( );   wp = g_status.window_list;   while (wp != NULL) {      if (wp->visible) {         show_ruler( wp );         show_ruler_pointer( wp );      }      wp = wp->next;   }}/* * Name:    make_popup_ruler * Purpose: create the popup ruler * Author:  Jason Hood * Date:    July 18, 2005 * Passed:  window:  window to display ruler *          line:    buffer for ruler characters *          attr:    buffer for ruler color *          len:     width of the window *          line1:   the units screen line *          line2:   the tens screen line * Notes:   the buffers are relative to the window's base column */void make_popup_ruler( TDE_WIN *window, text_ptr line, unsigned char *attr,                       int len, int line1, int line2 ){int  col;int  num, digit;   /*    * determine the starting column and number    */   col = ruler_win.rcol;   if (col >= window->bcol + len)      return;   if (col < window->bcol) {      num = window->bcol - ruler_win.rcol + 1;      col = 0;   } else {      num = 1;      col -= window->bcol;      len -= col;   }   if (num == 1  &&  col-1 >= 0) {      attr[col-1] = Color( Ruler );      line[col-1] = (window->rline == ruler_win.rline || window->cline == line1)                    ? RULER_EDGE : (line2 < line1) ? RULER_CRNRA : RULER_CRNRB;   }   if (window->rline == ruler_win.rline)      return;   memset( attr + col, Color( Ruler ), len );   digit = (num % 10) + '0';   num /= 10;   do {      if (window->cline == line1) {         line[col] = digit;         if (digit == '0'  &&  line1 == line2)            line[col] = windowletters[(num - 1) % strlen( windowletters )];      } else {         if (digit == '0')            my_ltoa( num, (char*)line + col - numlen( num ) + 1, 10 );         else            line[col] = RULER_LINE;      }      if (++digit > '9') {         digit = '0';         ++num;      }      ++col;   } while (--len);}/* * Name:    popup_ruler * Purpose: display and manipulate a ruler * Author:  Jason Hood * Date:    July 18, 2005 * Passed:  window:  pointer to current window * Notes:   pops up a ruler to count columns; also uses the line number *           display to count lines. */int  popup_ruler( TDE_WIN *window ){TDE_WIN dw;                             /* display window */DISPLAY_BUFF;int  i;long key;int  func;line_list_ptr ll;int  max, len;int  wid, hyt;int  bcol;long rline, last;int  lnum = FALSE;   dup_window_info( &dw, window );   hyt = dw.bottom_line - dw.top_line;   if (hyt < 1) {      /*       * need at least two lines       */      error( WARNING, dw.bottom_line, ruler_bad );      return( ERROR );

⌨️ 快捷键说明

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