/************************************************************************* * * 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 "tables.h" #include "input.h" #include #include #include const mstring star_tag="*"; const int PAD=2; const mstring HELP= "Commands from record page:\n" "\n" "DEL - Delete record\n" "RET - Edit record\n" "n - New record\n" "s - Sort by table\n" "o - Order by table\n" "c - Check for duplicates\n" "f - Filename for map\n" "r - Remove table\n" "a - Add table\n"; Tables::Tables() : from(0),lines(Lines()-1),atline(0),writable(0), tab(0),space(10),cols(Columns()),atcol(0), lastfrom(-1),lasttab(-1),lastline(0),lastcol(0) { dispcols=cols/space; } Tables::~Tables() { } void Tables::Setup(int sp) { space=sp; dispcols=cols/space; Home(); } void Tables::Show() { if(db.remap()) { lastfrom=-1; caption.convert("%d, %d, %d, %d", db.head()->filesize.get(), db.head()->fatal.get(), db.head()->major.get(), db.head()->minor.get()); } if(from!=lastfrom||tab!=lasttab) { ClearScreen(); Bold(1); for(int j=tab;j=0&&i<=db.size()&&j>=0&&j<=db.Tables()) { sref tmp; if(i=0&&i<=db.size()&&j>=0&&j<=db.Tables()) { sref tmp; if(i=db.size()) atline=db.size(); if(atline<0) atline=0; if(atline>=from+lines) from=atline+1-lines; if(atline=db.Tables()) atcol=db.Tables(); if(atcol<0) atcol=0; if(atcol>=tab+dispcols) tab=atcol+1-dispcols; if(atcol=0) { caption.convert("%s - added record",path.c_str()); Move(row-atline,0); } else { caption.convert("%s - record nonunique - not added",path.c_str()); Move(0,0); } } catch(const merror_t& e) { caption=e.desc; Move(0,0); } lastfrom=-1; } void Tables::Delete() { if(db.remap()) lastfrom=-1; if(atline