[BACK]Return to tty.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/tty.c between version 1.348 and 1.349

version 1.348, 2020/04/16 13:35:24 version 1.349, 2020/04/16 14:03:51
Line 74 
Line 74 
                     u_int);                      u_int);
   
 #define tty_use_margin(tty) \  #define tty_use_margin(tty) \
         ((tty->term->flags|tty->term_flags) & TERM_DECSLRM)          (tty_get_flags(tty) & TERM_DECSLRM)
   
 #define tty_pane_full_width(tty, ctx) \  #define tty_pane_full_width(tty, ctx) \
         ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx)          ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx)
Line 478 
Line 478 
                 tty_puts(tty, "\033[?69h"); /* DECLRMM */                  tty_puts(tty, "\033[?69h"); /* DECLRMM */
 }  }
   
   int
   tty_get_flags(struct tty *tty)
   {
           if (tty->term != NULL)
                   return (tty->term->flags|tty->term_flags);
           return (tty->term_flags);
   }
   
 void  void
 tty_raw(struct tty *tty, const char *s)  tty_raw(struct tty *tty, const char *s)
 {  {
Line 575 
Line 583 
 {  {
         const char      *acs;          const char      *acs;
   
         if ((tty->term->flags & TERM_NOXENL) &&          if ((tty_get_flags(tty) & TERM_NOXENL) &&
             ch >= 0x20 && ch != 0x7f &&              ch >= 0x20 && ch != 0x7f &&
             tty->cy == tty->sy - 1 &&              tty->cy == tty->sy - 1 &&
             tty->cx + 1 >= tty->sx)              tty->cx + 1 >= tty->sx)
Line 601 
Line 609 
                          * where we think it should be after a line wrap - this                           * where we think it should be after a line wrap - this
                          * means it works on sensible terminals as well.                           * means it works on sensible terminals as well.
                          */                           */
                         if (tty->term->flags & TERM_NOXENL)                          if (tty_get_flags(tty) & TERM_NOXENL)
                                 tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx);                                  tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx);
                 } else                  } else
                         tty->cx++;                          tty->cx++;
Line 611 
Line 619 
 void  void
 tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)  tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
 {  {
         if ((tty->term->flags & TERM_NOXENL) &&          if ((tty_get_flags(tty) & TERM_NOXENL) &&
             tty->cy == tty->sy - 1 &&              tty->cy == tty->sy - 1 &&
             tty->cx + len >= tty->sx)              tty->cx + len >= tty->sx)
                 len = tty->sx - tty->cx - 1;                  len = tty->sx - tty->cx - 1;
Line 1167 
Line 1175 
                  * background colour isn't default (because it doesn't work                   * background colour isn't default (because it doesn't work
                  * after SGR 0).                   * after SGR 0).
                  */                   */
                 if (((tty->term->flags|tty->term_flags) & TERM_DECFRA) &&                  if ((tty_get_flags(tty) & TERM_DECFRA) &&
                     !COLOUR_DEFAULT(bg)) {                      !COLOUR_DEFAULT(bg)) {
                         xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x",                          xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x",
                             py + 1, px + 1, py + ny, px + nx);                              py + 1, px + 1, py + ny, px + nx);
Line 1429 
Line 1437 
 void  void
 tty_sync_start(struct tty *tty)  tty_sync_start(struct tty *tty)
 {  {
         if ((tty->term->flags|tty->term_flags) & TERM_SYNC)          if (tty_get_flags(tty) & TERM_SYNC)
                 tty_puts(tty, "\033P=1s\033\\");                  tty_puts(tty, "\033P=1s\033\\");
 }  }
   
 void  void
 tty_sync_end(struct tty *tty)  tty_sync_end(struct tty *tty)
 {  {
         if ((tty->term->flags|tty->term_flags) & TERM_SYNC)          if (tty_get_flags(tty) & TERM_SYNC)
                 tty_puts(tty, "\033P=2s\033\\");                  tty_puts(tty, "\033P=2s\033\\");
 }  }
   
Line 1890 
Line 1898 
             ctx->xoff + ctx->ocx + ctx->num > ctx->ox + ctx->sx)) {              ctx->xoff + ctx->ocx + ctx->num > ctx->ox + ctx->sx)) {
                 if (!ctx->wrapped ||                  if (!ctx->wrapped ||
                     !tty_pane_full_width(tty, ctx) ||                      !tty_pane_full_width(tty, ctx) ||
                     (tty->term->flags & TERM_NOXENL) ||                      (tty_get_flags(tty) & TERM_NOXENL) ||
                     ctx->xoff + ctx->ocx != 0 ||                      ctx->xoff + ctx->ocx != 0 ||
                     ctx->yoff + ctx->ocy != tty->cy + 1 ||                      ctx->yoff + ctx->ocy != tty->cy + 1 ||
                     tty->cx < tty->sx ||                      tty->cx < tty->sx ||
Line 1951 
Line 1959 
         const struct grid_cell  *gcp;          const struct grid_cell  *gcp;
   
         /* Skip last character if terminal is stupid. */          /* Skip last character if terminal is stupid. */
         if ((tty->term->flags & TERM_NOXENL) &&          if ((tty_get_flags(tty) & TERM_NOXENL) &&
             tty->cy == tty->sy - 1 &&              tty->cy == tty->sy - 1 &&
             tty->cx == tty->sx - 1)              tty->cx == tty->sx - 1)
                 return;                  return;
Line 2110 
Line 2118 
 {  {
         if (!ctx->wrapped ||          if (!ctx->wrapped ||
             !tty_pane_full_width(tty, ctx) ||              !tty_pane_full_width(tty, ctx) ||
             (tty->term->flags & TERM_NOXENL) ||              (tty_get_flags(tty) & TERM_NOXENL) ||
             ctx->xoff + cx != 0 ||              ctx->xoff + cx != 0 ||
             ctx->yoff + cy != tty->cy + 1 ||              ctx->yoff + cy != tty->cy + 1 ||
             tty->cx < tty->sx ||              tty->cx < tty->sx ||
Line 2447 
Line 2455 
         /* Is this a 24-bit colour? */          /* Is this a 24-bit colour? */
         if (gc->fg & COLOUR_FLAG_RGB) {          if (gc->fg & COLOUR_FLAG_RGB) {
                 /* Not a 24-bit terminal? Translate to 256-colour palette. */                  /* Not a 24-bit terminal? Translate to 256-colour palette. */
                 if ((tty->term->flags|tty->term_flags) & TERM_RGBCOLOURS)                  if (tty_get_flags(tty) & TERM_RGBCOLOURS)
                         return;                          return;
                 colour_split_rgb(gc->fg, &r, &g, &b);                  colour_split_rgb(gc->fg, &r, &g, &b);
                 gc->fg = colour_find_rgb(r, g, b);                  gc->fg = colour_find_rgb(r, g, b);
         }          }
   
         /* How many colours does this terminal have? */          /* How many colours does this terminal have? */
         if ((tty->term->flags|tty->term_flags) & TERM_256COLOURS)          if (tty_get_flags(tty) & TERM_256COLOURS)
                 colours = 256;                  colours = 256;
         else          else
                 colours = tty_term_number(tty->term, TTYC_COLORS);                  colours = tty_term_number(tty->term, TTYC_COLORS);
Line 2496 
Line 2504 
         /* Is this a 24-bit colour? */          /* Is this a 24-bit colour? */
         if (gc->bg & COLOUR_FLAG_RGB) {          if (gc->bg & COLOUR_FLAG_RGB) {
                 /* Not a 24-bit terminal? Translate to 256-colour palette. */                  /* Not a 24-bit terminal? Translate to 256-colour palette. */
                 if ((tty->term->flags|tty->term_flags) & TERM_RGBCOLOURS)                  if (tty_get_flags(tty) & TERM_RGBCOLOURS)
                         return;                          return;
                 colour_split_rgb(gc->bg, &r, &g, &b);                  colour_split_rgb(gc->bg, &r, &g, &b);
                 gc->bg = colour_find_rgb(r, g, b);                  gc->bg = colour_find_rgb(r, g, b);
         }          }
   
         /* How many colours does this terminal have? */          /* How many colours does this terminal have? */
         if ((tty->term->flags|tty->term_flags) & TERM_256COLOURS)          if (tty_get_flags(tty) & TERM_256COLOURS)
                 colours = 256;                  colours = 256;
         else          else
                 colours = tty_term_number(tty->term, TTYC_COLORS);                  colours = tty_term_number(tty->term, TTYC_COLORS);
Line 2564 
Line 2572 
   
         /* Is this an aixterm bright colour? */          /* Is this an aixterm bright colour? */
         if (gc->fg >= 90 && gc->fg <= 97) {          if (gc->fg >= 90 && gc->fg <= 97) {
                 if (tty->term_flags & TERM_256COLOURS) {                  if (tty_get_flags(tty) & TERM_256COLOURS) {
                         xsnprintf(s, sizeof s, "\033[%dm", gc->fg);                          xsnprintf(s, sizeof s, "\033[%dm", gc->fg);
                         tty_puts(tty, s);                          tty_puts(tty, s);
                 } else                  } else
Line 2596 
Line 2604 
   
         /* Is this an aixterm bright colour? */          /* Is this an aixterm bright colour? */
         if (gc->bg >= 90 && gc->bg <= 97) {          if (gc->bg >= 90 && gc->bg <= 97) {
                 if (tty->term_flags & TERM_256COLOURS) {                  if (tty_get_flags(tty) & TERM_256COLOURS) {
                         xsnprintf(s, sizeof s, "\033[%dm", gc->bg + 10);                          xsnprintf(s, sizeof s, "\033[%dm", gc->bg + 10);
                         tty_puts(tty, s);                          tty_puts(tty, s);
                 } else                  } else
Line 2652 
Line 2660 
                  * Also if RGB is set, setaf and setab do not support the 256                   * Also if RGB is set, setaf and setab do not support the 256
                  * colour palette so use the sequences directly there too.                   * colour palette so use the sequences directly there too.
                  */                   */
                 if ((tty->term_flags & TERM_256COLOURS) ||                  if ((tty_get_flags(tty) & TERM_256COLOURS) ||
                     tty_term_has(tty->term, TTYC_RGB))                      tty_term_has(tty->term, TTYC_RGB))
                         goto fallback_256;                          goto fallback_256;
   
Line 2660 
Line 2668 
                  * If the terminfo entry has 256 colours and setaf and setab                   * If the terminfo entry has 256 colours and setaf and setab
                  * exist, assume that they work correctly.                   * exist, assume that they work correctly.
                  */                   */
                 if (tty->term->flags & TERM_256COLOURS) {                  if (tty_get_flags(tty) & TERM_256COLOURS) {
                         if (*type == '3') {                          if (*type == '3') {
                                 if (!tty_term_has(tty->term, TTYC_SETAF))                                  if (!tty_term_has(tty->term, TTYC_SETAF))
                                         goto fallback_256;                                          goto fallback_256;

Legend:
Removed from v.1.348  
changed lines
  Added in v.1.349