Esempio n. 1
0
void machmgr_draw_list() {
   unsigned char attr;
   const char *p;
   int w, h;
   int i, j;

   werase(listwin);
   getmaxyx(listwin, h, w);

   for (i = scrollpos; i < scrollpos + h && i < machcount; i++) {
      /* decide color */
      attr = machs[i]->alive ? 0x70 : 0x80;
      if (i == selmach)  attr &= 0xF0, attr |= 0x01; /* red background */
      if (machs[i]->tag) attr &= 0x0F, attr |= machs[i]->alive ? 0xA0 : 0x20;
                                                     /* green foreground */
      
      curutil_attrset(listwin, attr);
      wmove(listwin, i - scrollpos, 0);

      waddch(listwin, machs[i]->tag ? '*' : ' ');

      /* now we have to print the first w-2 characters of machs[i]->name,
       * padding with spaces at the end if necessary to complete w-2
       * characters. We say w-2 because one character of the width was
       * used up when printing '*' and another one must be left blank
       * at the end */
      p = machs[i]->name; j = w - 2;
      while (j--) {
         waddch(listwin, *p ? *p : ' ');
         if (*p) p++;
      }
   }
}
Esempio n. 2
0
bool minibuf_prompt(WINDOW *w, const char *prompt, unsigned char attr, 
                               char *buf, int len) {
   int pos = strlen(buf);
   int ch;
   int decision = 0;

   while (!decision) {
      werase(w);
      wmove(w, 0, 0);
      curutil_attrset(w, attr);
      waddstr(w, prompt);
      curutil_attrset(w, 0x70);
      waddstr(w, buf);
      wrefresh(w);
      
      ch = getch();
      if (ch < 0) continue;
      
      switch (ch) {
         case 127: case KEY_BACKSPACE: case '\b': 
            if (pos) pos--; break; /* bs */
         case ('U'-'A'+1):
            pos = 0; break;        /* ^U */
         
         case '\r': case '\n':
            decision = 1;   /* Enter */
            break;

         case ('C'-'A'+1): case ('G'-'A'+1): case 0x1B:
            decision = -1;  /* cancel */
            break;
      }

      if (ch >= 32 && ch != 127 && ch < 256 && pos + 1 < len)
         /* regular char, and we have room: put it in the buffer */
         buf[pos++] = ch;

      buf[pos] = 0;
   }
   
   werase(w);
   wrefresh(w);
   return decision == 1;
}
Esempio n. 3
0
void minibuf_put(WINDOW *w, const char *msg, unsigned char attr) {
   werase(w);
   wmove(w, 0, 0);

   if (msg) {
      curutil_attrset(w, attr);
      waddstr(w, msg);
   }

   wrefresh(w);
}
Esempio n. 4
0
void machmgr_draw_summary(WINDOW *w) {
   int i;
   int sumheight, sumwidth;
   char sumbuf[80];
   werase(w);
   wmove(w, 0, 0);
   getmaxyx(w, sumheight, sumwidth);
   
   for (i = scrollpos; i < scrollpos + sumheight && i < machcount; i++) {
      curutil_attrset(w, 0x80);
      wmove(w, i - scrollpos, 0);

      make_vt_summary(machs[i]->vt, sumbuf, sumwidth);
      waddstr(w, sumbuf);
   }
}