SaraF

fbpad-scrsnap.diff

Nov 13th, 2011
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.31 KB | None | 0 0
  1. --- a/Makefile  2011-11-13 01:01:34.394429572 -0500
  2. +++ b/Makefile  2011-11-13 01:04:32.024012806 -0500
  3. @@ -5,7 +5,7 @@
  4.  all: fbpad
  5.  %.o: %.c
  6.     $(CC) -c $(CFLAGS) $<
  7. -fbpad: fbpad.o term.o pad.o draw.o font.o
  8. +fbpad: fbpad.o term.o pad.o draw.o font.o scrsnap.o
  9.     $(CC) -o $@ $^ $(LDFLAGS)
  10.  clean:
  11.     rm -f *.o fbpad
  12. --- a/fbpad.c   2011-11-13 01:13:43.202630158 -0500
  13. +++ b/fbpad.c   2011-11-13 01:14:28.032518474 -0500
  14. @@ -20,6 +20,7 @@
  15.  #include "pad.h"
  16.  #include "term.h"
  17.  #include "util.h"
  18. +#include "scrsnap.h"
  19.  #include "draw.h"
  20.  
  21.  #define CTRLKEY(x) ((x) - 96)
  22. @@ -27,6 +28,7 @@
  23.  #define NTAGS      (sizeof(tags) - 1)
  24.  #define NTERMS     (NTAGS * 2)
  25.  #define TERMOPEN(i)    (terms[i].fd)
  26. +#define TERMSNAP(i)    (strchr(TAGS_SAVED, tags[(i) % NTAGS]))
  27.  
  28.  static char tags[] = TAGS;
  29.  static struct term terms[NTERMS];
  30. @@ -52,7 +54,11 @@
  31.  static void term_switch(int oidx, int nidx, int show, int save, int load)
  32.  {
  33.     int flags = show ? (load ? TERM_REDRAW : TERM_VISIBLE) : TERM_HIDDEN;
  34. +   if (save && TERMOPEN(oidx) && TERMSNAP(oidx))
  35. +                   scr_snap(&terms[oidx]);
  36.     term_save(&terms[oidx]);
  37. +   if (show && load && TERMOPEN(nidx) && TERMSNAP(nidx))
  38. +                   flags = scr_load(&terms[nidx]) ? TERM_REDRAW : TERM_VISIBLE;
  39.     term_load(&terms[nidx], flags);
  40.  }
  41.  
  42. @@ -104,7 +110,7 @@
  43.  
  44.  static void showtags(void)
  45.  {
  46. -   int colors[] = {15, 4, 2};
  47. +   int colors[] = {8, 2, 9};
  48.     int c = 0;
  49.     int r = pad_rows() - 1;
  50.     int i;
  51. @@ -121,7 +127,10 @@
  52.         if (TERMOPEN(altterm(i)))
  53.             nt++;
  54.         pad_put(i == ctag ? '(' : ' ', r, c++, FGCOLOR, BGCOLOR);
  55. -       pad_put(tags[i], r, c++, colors[nt], BGCOLOR);
  56. +       if (TERMSNAP(i))
  57. +                       pad_put(tags[i], r, c++, !nt ? 8 : colors[nt], BGCOLOR);
  58. +       else
  59. +                       pad_put(tags[i], r, c++, colors[nt], BGCOLOR);
  60.         pad_put(i == ctag ? ')' : ' ', r, c++, FGCOLOR, BGCOLOR);
  61.     }
  62.  }
  63. @@ -159,6 +168,9 @@
  64.         case 's':
  65.             term_screenshot();
  66.             return;
  67. +       case 'y':
  68. +           term_switch(cterm(), cterm(), 1, 0, 1);
  69. +           return;
  70.         default:
  71.             if (strchr(tags, c)) {
  72.                 showtag(strchr(tags, c) - tags);
  73. @@ -209,8 +221,10 @@
  74.         temp_switch(term_idx[i]);
  75.         if (ufds[i].revents & POLLIN)
  76.             term_read();
  77. -       if (ufds[i].revents & BADPOLLFLAGS)
  78. +       if (ufds[i].revents & BADPOLLFLAGS) {
  79. +           scr_free(&terms[cterm()]);
  80.             term_end();
  81. +       }
  82.         switch_back(term_idx[i]);
  83.     }
  84.     return 0;
  85.  
  86.  
Advertisement
Add Comment
Please, Sign In to add comment