📄 windiv.c
字号:
/* * windiv.c Some extra window routines for minicom, that * I did not want to fold into window.c * * This file is part of the minicom communications package, * Copyright 1991-1995 Miquel van Smoorenburg. * * This program 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 of the License, or (at your option) any later version. * * hgk+jl 02.98 File selection window (no longer used this way..) */#ifdef HAVE_CONFIG_H#include <config.h>#endif#include "rcsid.h"RCSID("$Id: windiv.c,v 1.8 2006/10/11 20:46:21 al-guest Exp $")#include <dirent.h>#include <sys/stat.h>#include "port.h"#include "minicom.h"#include "intl.h"#ifndef max #define max(a,b) ((a)>(b)?(a):(b))#endif#ifndef min #define min(a,b) ((a)<(b)?(a):(b))#endif/* * Popup a window and put a text in it. */static WIN *vmc_tell(const char *fmt, va_list va){ WIN *w; char buf[128]; if (stdwin == NULL) return NULL; vsnprintf(buf, sizeof(buf), fmt, va); w = wopen((COLS / 2) - 2 - mbslen(buf) / 2, 8, (COLS / 2) + 2 + mbslen(buf) / 2, 10, BDOUBLE, stdattr, mfcolor, mbcolor, 0, 0, 1); wcursor(w, CNONE); wlocate(w, 2, 1); wputs(w, buf); wredraw(w, 1); return w;}WIN *mc_tell(const char *s, ...){ WIN *w; va_list ap; va_start(ap, s); w = vmc_tell(s, ap); va_end(ap); return w;}/* * Show an error message. */void werror(const char *s, ...){ WIN *tellwin; va_list ap; va_start(ap, s); tellwin = vmc_tell(s, ap); va_end(ap); sleep(2); wclose(tellwin, 1);}/* * Vertical "wselect" function. */int ask(const char *what, const char **s){ int num = 0; int cur = 0, ocur = 0; int f, c; WIN *w; unsigned int size, offs; for (f = 0; s[f]; f++) num++; size = 5 * num; offs = 0; if (mbslen(what) > 2 * size + 4) { size = mbslen(what) / 2 + 2; offs = size - 5*num; } w = wopen((COLS / 2) - size , 8, (COLS / 2) + 1 + size, 9, BSINGLE, stdattr, mfcolor, mbcolor, 0, 0, 1); dirflush = 0; wcursor(w, CNONE); wlocate(w, 1 + size - (mbslen(what) / 2), 0); wputs(w, what); for (f = 1; f < num; f++) { wlocate(w, 2 + offs + 10*f, 1); wputs(w, _(s[f])); } wredraw(w, 1); while (1) { wlocate(w, 2 + offs + 10 * cur, 1); if (!useattr) wprintf(w, ">%s", _(s[cur]) + 1); else { wsetattr(w, XA_REVERSE | stdattr); wputs(w, _(s[cur])); } ocur = cur; wflush(); switch (c = wxgetch()) { case ' ': case 27: case 3: dirflush = 1; wclose(w, 1); return -1; case '\r': case '\n': dirflush = 1; wclose(w, 1); return cur; case K_LT: case 'h': cur--; if (cur < 0) cur = num - 1; break; default: cur = (cur + 1) % num; break; } wlocate(w, 2 + offs + 10 * ocur, 1); wsetattr(w, stdattr); if (!useattr) wputs(w, " "); else wputs(w, _(s[ocur])); }}/* * Popup a window and ask for input. */char *input(char *s, char *buf){ WIN *w; w = wopen((COLS / 2) - 20, 11, (COLS / 2) + 20, 12, BDOUBLE, stdattr, mfcolor, mbcolor, 1, 0, 1); wputs(w, s); wlocate(w, 0, 1); wprintf(w, "> %-38.38s", buf); wlocate(w, 2, 1); if (wgets(w, buf, 38, 128) < 0) buf = NULL; wclose(w, 1); return buf;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -