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

📄 window.c

📁 一个开源著名的TDE编辑器源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
            setup_window( win );            show_line_col( win );            show_curl_line( win );            if (file->dirty) {               redraw_current_window( wp );               file->dirty = FALSE;            } else {               show_window_header( wp );               show_ruler( wp );               if (wp->ll->next == NULL)                  show_eof( wp );               else                  show_curl_line( wp );            }            /*             * the new window becomes the current window.             */            g_status.current_window = wp;            show_window_count( );         }      }   }   return( rc );}/* * Name:    make_horizontal * Purpose: To split screen horizontally at the cursor. * Date:    June 5, 1991 * Modified: November 13, 1993, Frank Davis per Byrial Jensen * Passed:  window:  pointer to current window * Notes:   split the screen horizontally at the cursor position. *          the next hidden window becomes visible, or the next *           file is loaded. * * jmh 030323: replaced NewHorizontal with MakeHorizontal to resize the *              current window. */int  make_horizontal( TDE_WIN *window ){register TDE_WIN *wp;register TDE_WIN *win;  /* register pointer for window */int  half;int  top_line;int  change;const char *errmsg;int  rc;   rc = ERROR;   win = window;   if (win != NULL) {      /*       * check that there is room for the window       */      errmsg = NULL;      half = (g_status.command == MakeHalfHorizontal);      top_line = (half) ? ((win->top_line + win->bottom_line + 1) / 2)                        : win->cline;      if (top_line == win->top_line)         /*          * move cursor down first          */         errmsg = win1a;      else if (top_line == win->bottom_line)         /*          * move cursor up first          */         errmsg = win1;      if (errmsg) {         if (half)            /*             * window too small             */            errmsg = win1b;         error( WARNING, win->bottom_line, errmsg );      } else {         wp = find_make_window( win );         if (wp != NULL) {            un_copy_line( win->ll, win, TRUE, TRUE );            /*             * record that the current window has lost some lines from             *  the bottom for the new window, and adjust its page size             *  etc accordingly.             */            change = -1;            if (half) {               if (win->cline >= top_line)                  change = win->bottom_line - win->cline;            } else {               dec_line( win, TRUE );               --win->cline;            }            win->bottom_line = top_line - 1;            setup_window( win );            if (change >= 0) {               check_cline( win, win->bottom_line - change );               display_current_window( win );            } else {               show_line_col( win );               show_curl_line( win );            }            change  = wp->cline - wp->top_line;            wp->top = top_line;            if (wp->bottom_line == top_line + 1)               wp->ruler = FALSE;            setup_window( wp );            if (wp->cline < wp->top_line)               check_cline( wp, wp->top_line + change );            wp->visible = TRUE;            redraw_current_window( wp );         }      }   }   return( rc );}/* * Name:    split_vertical * Purpose: To split screen vertically at the cursor. * Date:    June 5, 1991 * Modified: November 13, 1993, Frank Davis per Byrial Jensen * Passed:  window:  pointer to current window * Notes:   split the screen vertically at the cursor position. * * Change:  Use of new function: get_next_letter( ) * * jmh 030227: added NewVertical function to load the next file instead of *              splitting the current. * jmh 030324: removed NewVertical; *             added Half version to split the window in half, leaving the *              cursor where it is. * jmh 030325: do an "actual" split - the left window has everything before *              the cursor, the right everything after (ie. the left and *              right columns do not change). */int  split_vertical( TDE_WIN *window ){register TDE_WIN *wp;register TDE_WIN *win;  /* register pointer for window */TDE_WIN *temp;file_infos *file;       /* file structure for file belonging to new window */int  half;int  left;int  change;const char *errmsg;int  rc;   rc = ERROR;   win = window;   if (win != NULL) {      /*       * check that there is room for the window       */      errmsg = NULL;      half = (g_status.command == SplitHalfVertical);      left = (half) ? ((win->left + win->end_col + 1) / 2)                    : win->ccol;      if (win->left + 15 > left)         /*          * move cursor right first          */         errmsg = win2;      else if (win->end_col - 15 < left)         /*          * move cursor left first          */         errmsg = win3;      if (errmsg) {         if (half)            /*             * window too small             */            errmsg = win1b;         error( WARNING, win->bottom_line, errmsg );      } else {         file = win->file_info;         assert( file != NULL );         rc = create_window( &temp, win->top, win->bottom_line,                             left+1, win->end_col, file );         if (rc == OK) {            wp = temp;            wp->visible = FALSE;            un_copy_line( win->ll, win, TRUE, TRUE );            wp->visible = TRUE;            /*             * set up the new cursor position as appropriate             */            wp->rline      = win->rline;            wp->bin_offset = win->bin_offset;            wp->ll         = win->ll;            wp->cline      = win->cline;            wp->rcol       = win->rcol;            wp->bcol       = win->bcol + left - win->left + 1;            wp->syntax     = win->syntax;            if (win->title)               wp->title = my_strdup( win->title );            change = win->ccol - left;            if (half  &&  change) {               if (change > 0) {                  wp->ccol = win->ccol;                  win->rcol -= change + 1;                  win->ccol = left - 1;               } else {                  wp->rcol -= change - 1;                  if (mode.line_numbers)                     wp->rcol += file->len_len;               }            } else {               --win->ccol;               --win->rcol;               ++wp->rcol;               if (mode.line_numbers)                  wp->rcol += file->len_len;            }            /*             * record that the current window has lost some columns from             *  the right for the new window             */            win->end_col  = left - 1;            win->vertical = TRUE;            wp->vertical  = TRUE;            redraw_current_window( win );            redraw_current_window( wp );            /*             * the new window becomes the current window.             */            g_status.current_window = wp;            show_window_count( );         }      }   }   return( rc );}/* * Name:    make_vertical * Purpose: To split screen vertically at the cursor. * Date:    June 5, 1991 * Modified: November 13, 1993, Frank Davis per Byrial Jensen * Passed:  window:  pointer to current window * Notes:   split the screen vertically at the cursor position. * * jmh 030324: replaced NewVertical with MakeVertical to resize the *              current window; */int  make_vertical( TDE_WIN *window ){register TDE_WIN *wp;register TDE_WIN *win;  /* register pointer for window */int  half;int  left;int  change;const char *errmsg;int  rc;   rc = ERROR;   win = window;   if (win != NULL) {      /*       * check that there is room for the window       */      errmsg = NULL;      half = (g_status.command == MakeHalfVertical);      left = (half) ? ((win->left + win->end_col + 1) / 2)                    : win->ccol;      if (win->left + 15 > left)         /*          * move cursor right first          */         errmsg = win2;      else if (win->end_col - 15 < left)         /*          * move cursor left first          */         errmsg = win3;      if (errmsg) {         if (half)            /*             * window too small             */            errmsg = win1b;         error( WARNING, win->bottom_line, errmsg );      } else {         wp = find_make_window( win );         if (wp != NULL) {            un_copy_line( win->ll, win, TRUE, TRUE );            /*             * record that the current window has lost some columns from             *  the right for the new window             */            change = -1;            if (half) {               if (win->ccol >= left)                  change = win->end_col - win->ccol;            } else {              --win->ccol;              --win->rcol;            }            win->end_col = left - 1;            if (change >= 0) {               win->ccol = win->end_col - change;               if (win->ccol < win->start_col)                  win->ccol = win->start_col;               win->bcol = win->rcol - (win->ccol - win->start_col);            }            win->vertical = TRUE;            redraw_current_window( win );            change = wp->ccol - wp->start_col;            wp->left = left + 1;            setup_window( wp );            if (wp->ccol < wp->start_col)               check_virtual_col( wp, wp->rcol, wp->start_col + change );            else               wp->bcol = wp->rcol - (wp->ccol - wp->start_col);            wp->vertical = TRUE;            wp->visible  = TRUE;            redraw_current_window( wp );            wp->file_info->dirty = FALSE;         }      }   }   return( rc );}/* * Name:    show_vertical_separator * Purpose: To separate vertical screens * Date:    June 5, 1991 * Passed:  window:  pointer to current window */void show_vertical_separator( TDE_WIN *window ){int  col;   col = window->left - 1;   if (col >= 0)      c_repeat( VERTICAL_CHAR, window->top - window->bottom_line - 1,                col, window->top, Color( Head ) );}/* * Name:    balance_horizontal * Purpose: make all windows the same height * Author:  Jason Hood * Date:    July 24, 2005 * Passed:  window:  pointer to current window * Notes:   all windows that have the same left and right edge as the current *           window will be made the same height. */int  balance_horizontal( TDE_WIN *window ){TDE_WIN *vis_win[20];int  visible = 0;TDE_WIN *win;int  top, bot, hyt;int  i, j, rem;   /*    * find all the visible windows that share edges with this window    */   top = g_display.mode_line;   bot = 0;   for (win = g_status.window_list; win != NULL; win = win->next) {      if (win->visible  &&  win->left    == window->left  &&                            win->end_col == window->end_col) {         if (visible == 20) {            /*             * too many windows             */            error( WARNING, window->bottom_line, win5 );            return( ERROR );         }         /*          * order windows top to bottom          */         for (i = 0; i < visible; ++i) {            if (win->top < vis_win[i]->top) {               memmove( vis_win+i+1, vis_win+i, (visible-i)*sizeof(TDE_WIN*) );               break;            }         }         vis_win[i] = win;         visible++;      }   }   /*    *   谀履

⌨️ 快捷键说明

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