/************************************************************************* * * HTCd - Copyright (C) 1998-2006 Henrik Rydberg * * 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. * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include int Lines() { return LINES-1; } int Columns() { return COLS-1; } void ClearScreen() { erase(); } void MoveCursor(int i,int j) { move(i,j); } void InitCurses() { initscr(); nodelay(stdscr,1); raw(); noecho(); nonl(); keypad(stdscr,1); intrflush(stdscr,FALSE); } void EndCurses() { endwin(); } void OutputField(int row,int col,int field,const sref& in) { mstring tmp=in.left_first_of(cset_newl); int cut=tmp.size()!=in.size(); if(tmp.size()field) { tmp.resize(field-1); tmp.append(1,'\\'); } mvaddstr(row,col,(char*)tmp.c_str()); } void Reverse(int n) { if(n) attron(A_REVERSE); else attroff(A_REVERSE); } void Bold(int n) { if(n) attron(A_BOLD); else attroff(A_BOLD); } void Refresh() { refresh(); } int RawInput() { int c=getch(); if(c>0) return c; struct pollfd ps={fileno(stdin),POLLIN,0}; poll(&ps,1,1000); return getch(); } int Input() { int c=RawInput(); #if 0 if(c==27) { napms(1); int c2=getch(); if(c2!=-1) { switch(c2) { default: return 0; case 91: switch(RawInput()) { default: return 0; case '2': RawInput(); switch(RawInput()) { default: return 0; case 52: return RawInput()==122?KEY_HOME:0; case 54: return RawInput()==122?KEY_PPAGE:0; case 48: return RawInput()==122?KEY_END:0; case 50: return RawInput()==122?KEY_NPAGE:0; } } } } } #endif return c; }