/* * wavemon - a wireless network monitoring aplication * * Copyright (c) 2001-2002 Jan Morgenstern * * wavemon is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2, or (at your option) any later * version. * * wavemon is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along * with wavemon; see the file COPYING. If not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "wavemon.h" /** * newwin_title - Create a new bordered window at (y, 0) * @y: vertical row position to start at * @h: height of the new window in lines * @title: name of the window * @nobottom: whether to keep the bottom of the box open */ WINDOW *newwin_title(int y, int h, const char *title, bool nobottom) { WINDOW *win = newwin(h, WAV_WIDTH, y, 0); chtype top_left = y > 0 ? ACS_LTEE : ACS_ULCORNER; chtype top_right = y > 0 ? ACS_RTEE : ACS_URCORNER; if (nobottom) { mvwaddch(win, 0, 0, top_left); mvwhline(win, 0, 1, ACS_HLINE, MAXXLEN); mvwvline(win, 1, 0, ACS_VLINE, h); mvwaddch(win, 0, WAV_WIDTH - 1, top_right); mvwvline(win, 1, WAV_WIDTH - 1, ACS_VLINE, h); } else { wborder(win, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, top_left, top_right, ACS_LLCORNER, ACS_LRCORNER); } wattrset(win, COLOR_PAIR(CP_WTITLE)); mvwaddstr(win, 0, 2, title); wattroff(win, COLOR_PAIR(CP_WTITLE)); return win; } /* clear inside window content up to the right border */ void mvwclrtoborder(WINDOW *win, int y, int x) { if (x >= 1 && x <= MAXXLEN) mvwhline(win, y, x, ' ', 1 + MAXXLEN - x); } void wclrtoborder(WINDOW *win) { int x, y; getyx(win, y, x); mvwclrtoborder(win, y, x); } void waddstr_center(WINDOW *win, int y, const char *s) { mvwaddstr(win, y, (WAV_WIDTH - strlen(s)) / 2, s); } void waddstr_b(WINDOW *win, const char *s) { wattron(win, A_BOLD); waddstr(win, s); wattroff(win, A_BOLD); } /* Enforce that @str is at most @len characters (excluding the terminal '\0') */ const char *curtail(const char *str, const char *sep, int len) { static char out_buf[128]; const char fallback_sep[] = "~"; int l = 0, front, mid, back; if (len >= sizeof(out_buf)) len = sizeof(out_buf) - 1; if (sep == NULL || *sep == '\0') sep = fallback_sep; mid = strlen(sep); if (mid > len) { sep = fallback_sep; mid = strlen(sep); } if (str != NULL) l = strlen(str); if (l <= len) return str; front = (len - mid)/2.0 + 0.5; back = len - front - mid; strncpy(out_buf, str, front); strncpy(out_buf + front, sep, mid); strncpy(out_buf + front + mid, str + l - back, back + 1); return out_buf; } static double interpolate(const double val, const double min, const double max) { return val < min ? 0 : val > max ? 1 : (val - min) / (max - min); } void waddbar(WINDOW *win, int y, float v, float min, float max, char *cscale, bool rev) { chtype ch = '=' | A_BOLD | cp_from_scale(v, cscale, rev); int len = MAXXLEN * interpolate(v, min, max); mvwhline(win, y, 1, ch, len); mvwclrtoborder(win, y, len + 1); } void waddthreshold(WINDOW *win, int y, float v, float tv, float minv, float maxv, char *cscale, chtype tch) { if (tv > minv && tv < maxv) { if (v > tv) tch |= COLOR_PAIR(CP_STANDARD); else tch |= cp_from_scale(v, cscale, true); mvwaddch(win, y, 1 + MAXXLEN * interpolate(tv, minv, maxv), tch); } } g?h=debian/1.4.8-3&id=b196c5e78140a90001870e7ae31ad5a1e818cd22&follow=1'>Upload to experimental.debian/1.4.8-1_exp1Jonathan McCrohan1-1/+1 2012-02-12Nitpicky typos.Jonathan McCrohan2-3/+3 2012-02-12Make changes as per JCristau's advice.Jonathan McCrohan1-9/+3 2012-02-11Remove unused entries from debian/rulesJonathan McCrohan1-2/+0 2012-02-11Fix typo in bugclose changelogJonathan McCrohan1-1/+1 2012-02-11Fix typo in libconfig++dev.examplesJonathan McCrohan1-3/+3 2012-02-11Update changelog.Jonathan McCrohan1-2/+5 2012-02-11Remove forced install of examples in rules.Jonathan McCrohan1-2/+2 2012-02-11Fix Examples.Jonathan McCrohan6-34/+17 2012-02-11Remove makefile.Jonathan McCrohan1-7/+0 2012-02-11Move *.docs, *.install and *.examples to -dev.Jonathan McCrohan7-2/+2 2012-02-11Move to single -dev package.Jonathan McCrohan2-14/+12 2012-02-08Update package changelog.Jonathan McCrohan1-1/+1 2012-02-08Partial manual revert of move to libconfig*8.Jonathan McCrohan4-12/+12 2012-02-08Add my name to debian copyright.Jonathan McCrohan1-2/+3 2012-02-08Atomic commit. Rollback to libconfig8 packaging names.Jonathan McCrohan10-8/+8 2012-02-07Rename libconfig9 to libconfig8 to aid release teamJonathan McCrohan1-14/+14 2012-02-07Fix "closes typo"Jonathan McCrohan1-1/+1 2012-02-07Revert "Add symbols"Jonathan McCrohan3-739/+1 2012-02-07Revert "Fix b0rked symbol file."Jonathan McCrohan1-1/+1 2012-02-07Revert "Second attempt"Jonathan McCrohan2-0/+194 2012-01-29Second attemptJonathan McCrohan2-194/+0 2012-01-29Fix b0rked symbol file.Jonathan McCrohan1-1/+1 2012-01-29Add symbolsJonathan McCrohan3-1/+739 2012-01-26add examples properlyJonathan McCrohan1-0/+2 2012-01-26Update changelogJonathan McCrohan1-3/+6 2012-01-26fix typoJonathan McCrohan1-1/+1 2012-01-26fix accidental description changesJonathan McCrohan1-2/+2 2012-01-26more fucking around to please lintianJonathan McCrohan1-5/+2 2012-01-25Linitan fixesJonathan McCrohan2-3/+2 2012-01-25Split out debug packagesJonathan McCrohan2-1/+6 2011-12-31Fix debian/rulesJonathan McCrohan1-1/+1 2011-12-31Remove shlibsJonathan McCrohan1-2/+0 2011-12-31Remove NMU from changelogJonathan McCrohan1-1/+0 2011-12-31Lintian FixesJonathan McCrohan1-2/+4 2011-12-31Remove Makefile patchJonathan McCrohan1-1/+0 2011-12-31Update MakefilesJonathan McCrohan10-248/+8222 2011-12-31Updated makefilesJonathan McCrohan1-0/+1