/[hurd]/hurd/console/display.c
ViewVC logotype

Diff of /hurd/console/display.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by marcus, Sat Jun 15 02:26:55 2002 UTC revision 1.8 by marcus, Mon Jun 17 01:42:06 2002 UTC
# Line 120  typedef struct output *output_t; Line 120  typedef struct output *output_t;
120    
121  struct attr  struct attr
122  {  {
123    /* Current attribute.  */    unsigned int bgcol_def;
124    char current;    unsigned int fgcol_def;
125    int fg;    conchar_attr_t current;
   int bg;  
   int def_fg;  
   int def_bg;  
   int reverse : 1;  
   int bold : 1;  
   int blink : 1;  
   int invisible : 1;  
   int dim : 1;  
   int underline : 1;  
126  };  };
127  typedef struct attr *attr_t;  typedef struct attr *attr_t;
128    
# Line 334  display_flush_filechange (display_t disp Line 325  display_flush_filechange (display_t disp
325  {  {
326    struct cons_display *user = display->user;    struct cons_display *user = display->user;
327    
328      if (type & DISPLAY_CHANGE_MATRIX
329          && display->changes.which & DISPLAY_CHANGE_MATRIX)
330        {
331          display_notice_filechange (display, FILE_CHANGED_WRITE,
332                                     sizeof (struct cons_display)
333                                     + display->changes.start * sizeof (conchar_t),
334                                     sizeof (struct cons_display)
335                                     + (display->changes.end + 1)
336                                     * sizeof (conchar_t) - 1);
337          type &= ~DISPLAY_CHANGE_MATRIX;
338        }
339    
340    if (type & DISPLAY_CHANGE_CURSOR_POS    if (type & DISPLAY_CHANGE_CURSOR_POS
341        || type & DISPLAY_CHANGE_CURSOR_STATUS)        || type & DISPLAY_CHANGE_CURSOR_STATUS)
342      {      {
# Line 358  display_flush_filechange (display_t disp Line 361  display_flush_filechange (display_t disp
361          }          }
362        if (len)        if (len)
363          display_notice_filechange (display, FILE_CHANGED_WRITE, start,          display_notice_filechange (display, FILE_CHANGED_WRITE, start,
364                                     start + len * sizeof (wchar_t) - 1);                                     start + len * sizeof (uint32_t) - 1);
365      }      }
366    
367    if (type & DISPLAY_CHANGE_SCREEN_CUR_LINE    if (type & DISPLAY_CHANGE_SCREEN_CUR_LINE
# Line 384  display_flush_filechange (display_t disp Line 387  display_flush_filechange (display_t disp
387          }          }
388        if (len)        if (len)
389          display_notice_filechange (display, FILE_CHANGED_WRITE, start,          display_notice_filechange (display, FILE_CHANGED_WRITE, start,
390                                     start + len * sizeof (wchar_t) - 1);                                     start + len * sizeof (uint32_t) - 1);
     }  
   
   if (type & DISPLAY_CHANGE_MATRIX  
       && display->changes.which & DISPLAY_CHANGE_MATRIX)  
     {  
       display_notice_filechange (display, FILE_CHANGED_WRITE,  
                                  sizeof (struct cons_display)  
                                  + display->changes.start * sizeof (wchar_t),  
                                  sizeof (struct cons_display)  
                                  + (display->changes.end + 1)  
                                  * sizeof (wchar_t) - 1);  
       type &= ~DISPLAY_CHANGE_MATRIX;  
391      }      }
392  }  }
393    
# Line 482  display_record_filechange (display_t dis Line 473  display_record_filechange (display_t dis
473                
474                            
475    
476    static void
477    conchar_memset (conchar_t *conchar, wchar_t chr, conchar_attr_t attr,
478                    size_t size)
479    {
480      int i;
481    
482      for (i = 0; i < size; i++)
483        {
484          conchar->chr = chr;
485          conchar->attr = attr;
486          conchar++;
487        }
488    }
489    
490  static error_t  static error_t
491  user_create (display_t display, uint32_t width, uint32_t height,  user_create (display_t display, uint32_t width, uint32_t height,
492               uint32_t lines)               uint32_t lines, wchar_t chr, conchar_attr_t attr)
493  {  {
494    error_t err;    error_t err;
495    struct cons_display *user;    struct cons_display *user;
496    
497    int npages = (round_page (sizeof (struct cons_display) +    int npages = (round_page (sizeof (struct cons_display) +
498                             sizeof (uint32_t) * width * lines)) / vm_page_size;                             sizeof (conchar_t) * width * lines)) / vm_page_size;
499    
500    display->upi = calloc (1, sizeof (struct user_pager_info)    display->upi = calloc (1, sizeof (struct user_pager_info)
501                           + sizeof (vm_address_t) * npages);                           + sizeof (vm_address_t) * npages);
# Line 539  user_create (display_t display, uint32_t Line 545  user_create (display_t display, uint32_t
545    user->cursor.col = 0;    user->cursor.col = 0;
546    user->cursor.row = 0;    user->cursor.row = 0;
547    user->cursor.status = CONS_CURSOR_NORMAL;    user->cursor.status = CONS_CURSOR_NORMAL;
548    wmemset (user->_matrix, L' ', user->screen.width * user->screen.lines);    conchar_memset (user->_matrix, chr, attr,
549                      user->screen.width * user->screen.lines);
550    
   /* XXX Set attribute flags.  */  
551    display->user = user;    display->user = user;
552    return 0;    return 0;
553  }  }
# Line 556  user_destroy (display_t display) Line 562  user_destroy (display_t display)
562    
563  static void  static void
564  screen_fill (display_t display, size_t col1, size_t row1, size_t col2,  screen_fill (display_t display, size_t col1, size_t row1, size_t col2,
565               size_t row2, wchar_t chr, char attr)               size_t row2, wchar_t chr, conchar_attr_t attr)
566  {  {
567    struct cons_display *user = display->user;    struct cons_display *user = display->user;
568    off_t start = (user->screen.cur_line + row1) * user->screen.width + col1;    off_t start = (user->screen.cur_line + row1) * user->screen.width + col1;
# Line 571  screen_fill (display_t display, size_t c Line 577  screen_fill (display_t display, size_t c
577    
578    if (end < size)    if (end < size)
579      {      {
580        wmemset (user->_matrix + start, chr, end - start + 1);        conchar_memset (user->_matrix + start, chr, attr, end - start + 1);
581        display_record_filechange (display, start, end);        display_record_filechange (display, start, end);
582      }      }
583    else    else
584      {      {
585        wmemset (user->_matrix + start, chr, size - start);        conchar_memset (user->_matrix + start, chr, attr, size - start);
586        wmemset (user->_matrix, chr, end - size + 1);        conchar_memset (user->_matrix, chr, attr, end - size + 1);
587        display_record_filechange (display, start, end - size);        display_record_filechange (display, start, end - size);
588      }      }
589  }  }
590    
591  static void  static void
592  screen_shift_left (display_t display, size_t col1, size_t row1, size_t col2,  screen_shift_left (display_t display, size_t col1, size_t row1, size_t col2,
593                     size_t row2, size_t shift, wchar_t chr, char attr)                     size_t row2, size_t shift, wchar_t chr, conchar_attr_t attr)
594  {  {
595    struct cons_display *user = display->user;    struct cons_display *user = display->user;
596    off_t start = (user->screen.cur_line + row1) * user->screen.width + col1;    off_t start = (user->screen.cur_line + row1) * user->screen.width + col1;
# Line 607  screen_shift_left (display_t display, si Line 613  screen_shift_left (display_t display, si
613        while (src <= end)        while (src <= end)
614          user->_matrix[dst++ % size] = user->_matrix[src++ % size];          user->_matrix[dst++ % size] = user->_matrix[src++ % size];
615        while (dst <= end)        while (dst <= end)
616          user->_matrix[dst++ % size] = chr;          {
617              user->_matrix[dst++ % size].chr = chr;
618              user->_matrix[dst++ % size].attr = attr;
619            }
620    
621        display_record_filechange (display, start, end);        display_record_filechange (display, start, end);
622  #if 0  #if 0
623        display_flush_filechange (display, DISPLAY_CHANGE_MATRIX);        display_flush_filechange (display, DISPLAY_CHANGE_MATRIX);
624        display_notice_filechange (display, FILE_CHANGED_TRUNCATE,        display_notice_filechange (display, FILE_CHANGED_TRUNCATE,
625                                   sizeof (struct cons_display)                                   sizeof (struct cons_display)
626                                   + start * sizeof (wchar_t),                                   + start * sizeof (conchar_t),
627                                   sizeof (struct cons_display)                                   sizeof (struct cons_display)
628                                   + (start + shift) * sizeof (wchar_t) - 1);                                   + (start + shift) * sizeof (conchar_t) - 1);
629        display_notice_filechange (display, FILE_CHANGED_EXTEND,        display_notice_filechange (display, FILE_CHANGED_EXTEND,
630                                   sizeof (struct cons_display)                                   sizeof (struct cons_display)
631                                   + (end - shift + 1) * sizeof (wchar_t),                                   + (end - shift + 1) * sizeof (conchar_t),
632                                   sizeof (struct cons_display)                                   sizeof (struct cons_display)
633                                   + (end + 1) * sizeof (wchar_t) - 1);                                   + (end + 1) * sizeof (conchar_t) - 1);
634  #endif  #endif
635      }      }
636    else    else
# Line 630  screen_shift_left (display_t display, si Line 639  screen_shift_left (display_t display, si
639    
640  static void  static void
641  screen_shift_right (display_t display, size_t col1, size_t row1, size_t col2,  screen_shift_right (display_t display, size_t col1, size_t row1, size_t col2,
642                      size_t row2, size_t shift, wchar_t chr, char attr)                      size_t row2, size_t shift,
643                        wchar_t chr, conchar_attr_t attr)
644  {  {
645    struct cons_display *user = display->user;    struct cons_display *user = display->user;
646    off_t start = (user->screen.cur_line + row1) * user->screen.width + col1;    off_t start = (user->screen.cur_line + row1) * user->screen.width + col1;
# Line 653  screen_shift_right (display_t display, s Line 663  screen_shift_right (display_t display, s
663        while (src >= start)        while (src >= start)
664          user->_matrix[dst-- % size] = user->_matrix[src-- % size];          user->_matrix[dst-- % size] = user->_matrix[src-- % size];
665        while (dst >= start)        while (dst >= start)
666          user->_matrix[dst-- % size] = chr;          {
667              user->_matrix[dst-- % size].chr = chr;
668              user->_matrix[dst-- % size].attr = attr;
669            }
670    
671        display_record_filechange (display, start, end);        display_record_filechange (display, start, end);
672  #if 0  #if 0
673        display_flush_filechange (display, DISPLAY_CHANGE_MATRIX);        display_flush_filechange (display, DISPLAY_CHANGE_MATRIX);
674        display_notice_filechange (display, FILE_CHANGED_EXTEND,        display_notice_filechange (display, FILE_CHANGED_EXTEND,
675                                   sizeof (struct cons_display)                                   sizeof (struct cons_display)
676                                   + start * sizeof (wchar_t),                                   + start * sizeof (conchar_t),
677                                   sizeof (struct cons_display)                                   sizeof (struct cons_display)
678                                   + (start + shift) * sizeof (wchar_t) - 1);                                   + (start + shift) * sizeof (conchar_t) - 1);
679        display_notice_filechange (display, FILE_CHANGED_TRUNCATE,        display_notice_filechange (display, FILE_CHANGED_TRUNCATE,
680                                   sizeof (struct cons_display)                                   sizeof (struct cons_display)
681                                   + (end - shift + 1) * sizeof (wchar_t),                                   + (end - shift + 1) * sizeof (conchar_t),
682                                   sizeof (struct cons_display)                                   sizeof (struct cons_display)
683                                   + (end + 1) * sizeof (wchar_t) - 1);                                   + (end + 1) * sizeof (conchar_t) - 1);
684  #endif  #endif
685      }      }
686    else    else
# Line 721  handle_esc_bracket_m (attr_t attr, int c Line 734  handle_esc_bracket_m (attr_t attr, int c
734      {      {
735      case 0:      case 0:
736        /* All attributes off: <sgr0>.  */        /* All attributes off: <sgr0>.  */
737        attr->fg = attr->def_fg;        memset (&attr->current, 0, sizeof (conchar_attr_t));
738        attr->bg = attr->def_bg;        attr->current.fgcol = attr->fgcol_def;
739        attr->reverse = attr->bold = attr->blink        attr->current.bgcol = attr->bgcol_def;
         = attr->invisible = attr->dim  
         = attr->underline = 0;  
       /* Cursor attributes aren't text attributes.  */  
740        break;        break;
741      case 1:      case 1:
742        /* Bold on: <bold>.  */        /* Bold on: <bold>.  */
743        attr->bold = 1;        attr->current.intensity = CONS_ATTR_INTENSITY_BOLD;
744        break;        break;
745      case 2:      case 2:
746        /* Dim on: <dim>.  */        /* Dim on: <dim>.  */
747        attr->dim = 1;        attr->current.intensity = CONS_ATTR_INTENSITY_DIM;
748        break;        break;
749      case 4:      case 4:
750        /* Underline on: <smul>.  */        /* Underline on: <smul>.  */
751        attr->underline = 1;        attr->current.underlined = 1;
752        break;        break;
753      case 5:      case 5:
754        /* Blink on: <blink>.  */        /* (Slow) blink on: <blink>.  */
755        attr->blink = 1;        attr->current.blinking = 1;
756        break;        break;
757      case 7:      case 7:
758        /* Reverse video on: <rev>, <smso>.  */        /* Reverse video on: <rev>, <smso>.  */
759        attr->reverse = 1;        attr->current.reversed = 1;
760        break;        break;
761      case 8:      case 8:
762        /* Concealed on: <invis>.  */        /* Concealed on: <invis>.  */
763        attr->invisible = 1;        attr->current.concealed = 1;
       break;  
     case 21:  
       /* Bold Off.  */  
       attr->bold = 0;  
764        break;        break;
765      case 22:      case 22:
766        /* Dim off.  */        /* Normal intensity.  */
767        attr->dim = 0;        attr->current.intensity = CONS_ATTR_INTENSITY_NORMAL;
768        break;        break;
769      case 24:      case 24:
770        /* Underline off: <rmul>.  */        /* Underline off: <rmul>.  */
771        attr->underline = 0;        attr->current.underlined = 0;
772        break;        break;
773      case 25:      case 25:
774        /* Blink off.  */        /* Blink off.  */
775        attr->blink = 0;        attr->current.blinking = 0;
776        break;        break;
777      case 27:      case 27:
778        /* Reverse video off: <rmso>.  */        /* Reverse video off: <rmso>.  */
779        attr->reverse = 0;        attr->current.reversed = 0;
780        break;        break;
781      case 28:      case 28:
782        /* Concealed off.  */        /* Concealed off.  */
783        attr->invisible = 0;        attr->current.concealed = 0;
784        break;        break;
785      case 30 ... 37:      case 30 ... 37:
786        /* Set foreground color: <setaf>.  */        /* Set foreground color: <setaf>.  */
787        attr->fg = code - 30;        attr->current.fgcol = code - 30;
788        break;        break;
789      case 39:      case 39:
790        /* Default foreground color; ANSI?.  */        /* Default foreground color; ANSI?.  */
791        attr->fg = attr->def_fg;        attr->current.fgcol = attr->fgcol_def;
792        break;        break;
793      case 40 ... 47:      case 40 ... 47:
794        /* Set background color: <setab>.  */        /* Set background color: <setab>.  */
795        attr->bg = code - 40;        attr->current.bgcol = code - 40;
796        break;        break;
797      case 49:      case 49:
798        /* Default background color; ANSI?.  */        /* Default background color; ANSI?.  */
799        attr->bg = attr->def_bg;        attr->current.bgcol = attr->bgcol_def;
800        break;        break;
801      }      }
   /* XXX */  
   /* recalc_attr (display); */  
802  }  }
803    
804  static void  static void
# Line 821  handle_esc_bracket (display_t display, c Line 825  handle_esc_bracket (display_t display, c
825    
826    switch (op)    switch (op)
827      {      {
828      case 'H':      case 'H':           /* ECMA-48 <CUP>.  */
829      case 'f':      case 'f':           /* ECMA-48 <HVP>.  */
830        /* Cursor position: <cup>.  */        /* Cursor position: <cup>.  */
831        user->cursor.col = parse->params[1] - 1;        user->cursor.col = (parse->params[1] ?: 1) - 1;
832        user->cursor.row = parse->params[0] - 1;        user->cursor.row = (parse->params[0] ?: 1) - 1;
833          limit_cursor ();
834          break;
835        case 'G':           /* ECMA-48 <CHA>.  */
836        case '`':           /* ECMA-48 <HPA>.  */
837          /* Horizontal cursor position: <hpa>.  */
838          user->cursor.col = (parse->params[0] ?: 1) - 1;
839        limit_cursor ();        limit_cursor ();
840        break;        break;
841      case 'G':      case 'd':           /* ECMA-48 <VPA>.  */
842        /* Horizontal position: <hpa>.  */        /* Vertical cursor position: <hpa>.  */
843        user->cursor.col = parse->params[0] - 1;        user->cursor.row = (parse->params[0] ?: 1) - 1;
844        limit_cursor ();        limit_cursor ();
845        break;        break;
846      case 'F':      case 'F':           /* ECMA-48 <CPL>.  */
847        /* Beginning of previous line.  */        /* Beginning of previous line.  */
848        user->cursor.col = 0;        user->cursor.col = 0;
849        /* fall through */        /* Fall through.  */
850      case 'A':      case 'A':           /* ECMA-48 <CUU>.  */
851        case 'k':           /* ECMA-48 <VPB>.  */
852        /* Cursor up: <cuu>, <cuu1>.  */        /* Cursor up: <cuu>, <cuu1>.  */
853        user->cursor.row -= (parse->params[0] ?: 1);        user->cursor.row -= (parse->params[0] ?: 1);
854        limit_cursor ();        limit_cursor ();
855        break;        break;
856      case 'E':      case 'E':           /* ECMA-48 <CNL>.  */
857        /* Beginning of next line.  */        /* Beginning of next line.  */
858        user->cursor.col = 0;        user->cursor.col = 0;
859        /* Fall through.  */        /* Fall through.  */
860      case 'B':      case 'B':           /* ECMA-48 <CUD>.  */
861        case 'e':           /* ECMA-48 <VPR>.  */
862        /* Cursor down: <cud1>, <cud>.  */        /* Cursor down: <cud1>, <cud>.  */
863        user->cursor.row += (parse->params[0] ?: 1);        user->cursor.row += (parse->params[0] ?: 1);
864        limit_cursor ();        limit_cursor ();
865        break;        break;
866      case 'C':      case 'C':           /* ECMA-48 <CUF>.  */
867        /* Cursor right: <cuf1>, <cuf>.  */        /* Cursor right: <cuf1>, <cuf>.  */
868        user->cursor.col += (parse->params[0] ?: 1);        user->cursor.col += (parse->params[0] ?: 1);
869        limit_cursor ();        limit_cursor ();
870        break;        break;
871      case 'D':      case 'D':           /* ECMA-48 <CUB>.  */
872        /* Cursor left: <cub>, <cub1>.  */        /* Cursor left: <cub>, <cub1>.  */
873        user->cursor.col -= (parse->params[0] ?: 1);        user->cursor.col -= (parse->params[0] ?: 1);
874        limit_cursor ();        limit_cursor ();
# Line 883  handle_esc_bracket (display_t display, c Line 895  handle_esc_bracket (display_t display, c
895        for (i = 0; i < parse->nparams; i++)        for (i = 0; i < parse->nparams; i++)
896          handle_esc_bracket_hl (display, parse->params[i], 1);          handle_esc_bracket_hl (display, parse->params[i], 1);
897        break;        break;
898      case 'm':      case 'm':           /* ECME-48 <SGR>.  */
899        for (i = 0; i < parse->nparams; i++)        for (i = 0; i < parse->nparams; i++)
900          handle_esc_bracket_m (&display->attr, parse->params[i]);          handle_esc_bracket_m (&display->attr, parse->params[i]);
901        break;        break;
902      case 'J':      case 'J':           /* ECME-48 <ED>.  */
903        switch (parse->params[0])        switch (parse->params[0])
904          {          {
905          case 0:          case 0:
# Line 910  handle_esc_bracket (display_t display, c Line 922  handle_esc_bracket (display_t display, c
922            break;            break;
923          }          }
924        break;        break;
925      case 'K':      case 'K':           /* ECME-48 <EL>.  */
926        switch (parse->params[0])        switch (parse->params[0])
927          {          {
928          case 0:          case 0:
# Line 933  handle_esc_bracket (display_t display, c Line 945  handle_esc_bracket (display_t display, c
945            break;            break;
946          }          }
947        break;        break;
948      case 'L':      case 'L':           /* ECME-48 <IL>.  */
949        /* Insert line(s): <il1>, <il>.  */        /* Insert line(s): <il1>, <il>.  */
950        screen_shift_right (display, 0, user->cursor.row,        screen_shift_right (display, 0, user->cursor.row,
951                            user->screen.width - 1, user->screen.height - 1,                            user->screen.width - 1, user->screen.height - 1,
952                            (parse->params[0] ?: 1) * user->screen.width,                            (parse->params[0] ?: 1) * user->screen.width,
953                            L' ', display->attr.current);                            L' ', display->attr.current);
954        break;        break;
955      case 'M':      case 'M':           /* ECME-48 <DL>.  */
956        /* Delete line(s): <dl1>, <dl>.  */        /* Delete line(s): <dl1>, <dl>.  */
957        screen_shift_left (display, 0, user->cursor.row,        screen_shift_left (display, 0, user->cursor.row,
958                           user->screen.width - 1, user->screen.height - 1,                           user->screen.width - 1, user->screen.height - 1,
959                           (parse->params[0] ?: 1) * user->screen.width,                           (parse->params[0] ?: 1) * user->screen.width,
960                           L' ', display->attr.current);                           L' ', display->attr.current);
961        break;        break;
962      case '@':      case '@':           /* ECME-48 <ICH>.  */
963        /* Insert character(s): <ich1>, <ich>.  */        /* Insert character(s): <ich1>, <ich>.  */
964        screen_shift_right (display, user->cursor.col, user->cursor.row,        screen_shift_right (display, user->cursor.col, user->cursor.row,
965                            user->screen.width - 1, user->cursor.row,                            user->screen.width - 1, user->cursor.row,
966                            parse->params[0] ?: 1,                            parse->params[0] ?: 1,
967                            L' ', display->attr.current);                            L' ', display->attr.current);
968        break;        break;
969      case 'P':      case 'P':           /* ECME-48 <DCH>.  */
970        /* Delete character(s): <dch1>, <dch>.  */        /* Delete character(s): <dch1>, <dch>.  */
971        screen_shift_left (display, user->cursor.col, user->cursor.row,        screen_shift_left (display, user->cursor.col, user->cursor.row,
972                           user->screen.width - 1, user->cursor.row,                           user->screen.width - 1, user->cursor.row,
973                           parse->params[0] ?: 1,                           parse->params[0] ?: 1,
974                           L' ', display->attr.current);                           L' ', display->attr.current);
975        break;        break;
976      case 'S':      case 'S':           /* ECME-48 <SU>.  */
977        /* Scroll up: <ind>, <indn>.  */        /* Scroll up: <ind>, <indn>.  */
978        screen_shift_left (display, 0, 0,        screen_shift_left (display, 0, 0,
979                           user->screen.width - 1, user->screen.height - 1,                           user->screen.width - 1, user->screen.height - 1,
980                           (parse->params[0] ?: 1) * user->screen.width,                           (parse->params[0] ?: 1) * user->screen.width,
981                           L' ', display->attr.current);                           L' ', display->attr.current);
982        break;        break;
983      case 'T':      case 'T':           /* ECME-48 <SD>.  */
984        /* Scroll down: <ri>, <rin>.  */        /* Scroll down: <ri>, <rin>.  */
985        screen_shift_right (display, 0, 0,        screen_shift_right (display, 0, 0,
986                            user->screen.width, user->screen.height,                            user->screen.width, user->screen.height,
987                            (parse->params[0] ?: 1) * user->screen.width,                            (parse->params[0] ?: 1) * user->screen.width,
988                            L' ', display->attr.current);                            L' ', display->attr.current);
989        break;        break;
990      case 'X':      case 'X':           /* ECME-48 <ECH>.  */
991        /* Erase character(s): <ech>.  */        /* Erase character(s): <ech>.  */
992        screen_fill (display, user->cursor.col, user->cursor.row,        screen_fill (display, user->cursor.col, user->cursor.row,
993                     /* XXX limit ? */user->cursor.col + parse->params[0] ?: 1,                     /* XXX limit ? */user->cursor.col + (parse->params[0] ?: 1),
994                     user->cursor.row,                     user->cursor.row,
995                     L' ', display->attr.current);                     L' ', display->attr.current);
996        break;        break;
# Line 1030  display_output_one (display_t display, w Line 1042  display_output_one (display_t display, w
1042    struct cons_display *user = display->user;    struct cons_display *user = display->user;
1043    parse_t parse = &display->output.parse;    parse_t parse = &display->output.parse;
1044    
1045    void newline (void)    void linefeed (void)
1046      {      {
1047        if (user->cursor.row < user->screen.height - 1)        if (user->cursor.row < user->screen.height - 1)
1048          {          {
# Line 1042  display_output_one (display_t display, w Line 1054  display_output_one (display_t display, w
1054            user->screen.cur_line++;            user->screen.cur_line++;
1055            user->screen.cur_line %= user->screen.lines;            user->screen.cur_line %= user->screen.lines;
1056    
           /* XXX Set attribute flags.  */  
1057            screen_fill (display, 0, user->screen.height - 1,            screen_fill (display, 0, user->screen.height - 1,
1058                         user->screen.width - 1, user->screen.height - 1,                         user->screen.width - 1, user->screen.height - 1,
1059                         L' ', user->screen.width);                         L' ', display->attr.current);
1060            if (user->screen.scr_lines <            if (user->screen.scr_lines <
1061                user->screen.lines - user->screen.height)                user->screen.lines - user->screen.height)
1062              user->screen.scr_lines++;              user->screen.scr_lines++;
# Line 1068  display_output_one (display_t display, w Line 1079  display_output_one (display_t display, w
1079              }              }
1080            break;            break;
1081          case L'\n':          case L'\n':
1082            /* Cursor down: <cud1>, scroll up: <ind>.  */            /* Line feed.  */
1083            newline ();            linefeed ();
1084            break;            break;
1085          case L'\b':          case L'\b':
1086            /* Cursor backward: <cub1>.  */            /* Backspace.  */
1087            if (user->cursor.col > 0 || user->cursor.row > 0)            if (user->cursor.col > 0 || user->cursor.row > 0)
1088              {              {
1089                if (user->cursor.col > 0)                if (user->cursor.col > 0)
# Line 1093  display_output_one (display_t display, w Line 1104  display_output_one (display_t display, w
1104            if (user->cursor.col >= user->screen.width)            if (user->cursor.col >= user->screen.width)
1105              {              {
1106                user->cursor.col = 0;                user->cursor.col = 0;
1107                newline ();                linefeed ();
1108              }              }
1109            /* XXX Flag cursor update.  */            /* XXX Flag cursor update.  */
1110            break;            break;
# Line 1108  display_output_one (display_t display, w Line 1119  display_output_one (display_t display, w
1119              int line = (user->screen.cur_line + user->cursor.row)              int line = (user->screen.cur_line + user->cursor.row)
1120                % user->screen.lines;                % user->screen.lines;
1121              int idx = line * user->screen.width + user->cursor.col;              int idx = line * user->screen.width + user->cursor.col;
1122              /* XXX Set attribute flags.  */              user->_matrix[idx].chr = chr;
1123              user->_matrix[idx] = chr;              user->_matrix[idx].attr = display->attr.current;
1124    
1125              display_record_filechange (display, idx, idx);              display_record_filechange (display, idx, idx);
1126              user->cursor.col++;              user->cursor.col++;
1127              if (user->cursor.col == user->screen.width)              if (user->cursor.col == user->screen.width)
1128                {                {
1129                  user->cursor.col = 0;                  user->cursor.col = 0;
1130                  newline ();                  linefeed ();
1131                }                }
1132            }            }
1133            break;            break;
# Line 1138  display_output_one (display_t display, w Line 1149  display_output_one (display_t display, w
1149            /* XXX Flag cursor change.  */            /* XXX Flag cursor change.  */
1150            parse->state = STATE_NORMAL;            parse->state = STATE_NORMAL;
1151            break;            break;
1152            case L'E':              /* ECMA-48 <NEL>.  */
1153              /* Newline.  */
1154              user->cursor.col = 0;
1155              linefeed ();
1156              break;
1157          default:          default:
1158            /* Unsupported escape sequence.  */            /* Unsupported escape sequence.  */
1159            parse->state = STATE_NORMAL;            parse->state = STATE_NORMAL;
1160            break;            break;
1161          }          }
1162        break;        break;
1163          
1164      case STATE_ESC_BRACKET_INIT:      case STATE_ESC_BRACKET_INIT:
1165        memset (&parse->params, 0, sizeof parse->params);        memset (&parse->params, 0, sizeof parse->params);
1166        parse->nparams = 0;        parse->nparams = 0;
# Line 1251  display_create (display_t *r_display, co Line 1267  display_create (display_t *r_display, co
1267    display_t display;    display_t display;
1268    int width = 80;    int width = 80;
1269    int height = 25;    int height = 25;
1270    int lines = 25;       /* XXX For now.  */    int lines = 50;       /* XXX For now.  */
1271    
1272    *r_display = NULL;    *r_display = NULL;
1273    display = calloc (1, sizeof *display);    display = calloc (1, sizeof *display);
# Line 1259  display_create (display_t *r_display, co Line 1275  display_create (display_t *r_display, co
1275      return ENOMEM;      return ENOMEM;
1276    
1277    mutex_init (&display->lock);    mutex_init (&display->lock);
1278    err = user_create (display, width, height, lines);    display->attr.bgcol_def = CONS_COLOR_BLACK;
1279      display->attr.fgcol_def = CONS_COLOR_WHITE;
1280      display->attr.current.bgcol = display->attr.bgcol_def;
1281      display->attr.current.fgcol = display->attr.fgcol_def;
1282      err = user_create (display, width, height, lines, L' ',
1283                         display->attr.current);
1284    if (err)    if (err)
1285      {      {
1286        free (display);        free (display);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26