/* TUIpeer works in conjunction with an implementation of java.awt.Toolkit to provide a Text User Interface for programs using the Java AWT. Copyright (C) 1997-2000 Stuart D. Gathman 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #pragma interface #include #include #include #include struct BrowserBase: virtual Controller { enum Dir { DIR_UP,DIR_DOWN,DIR_LEFT,DIR_RIGHT,DIR_NONE }; enum { EDIT_INSLINE = 100, EDIT_DELLINE, EDIT_MARKBLK, EDIT_PASTE, EDIT_GRAPH, EDIT_FWD, EDIT_REV, EDIT_REFORM, EDIT_SEARCH, EDIT_AGAIN, EDIT_WORDWRAP, FILE_PRINT = 50 }; BrowserBase(); ~BrowserBase(); void key(int); void cmd(int); virtual CHTYPE operator()(int row,int col) const = 0; // inspect virtual void getyx(int &, int &) const = 0; // get logical cursor location virtual void move(int row, int col) = 0; // move point, update topline virtual Dimension size() const = 0; // size of window virtual void sync(); // update desc virtual void print() { } virtual void search(const char *) { } string getname() const { return name; } void move(Dir); // move in a direction protected: string name,pat; int topline, leftcol; // updated by move() char desc[40]; mutable bool modified; private: BrowserBase(const BrowserBase &); BrowserBase&operator=(const BrowserBase &); }; struct EditorBase: virtual BrowserBase { EditorBase(); ~EditorBase(); void key(int); void cmd(int); virtual void addch(char) = 0; // replace virtual void insch(char) = 0; // insert virtual void delch() = 0; // delete virtual void insertln(int) = 0; virtual void deleteln(int) = 0; virtual void sync(); // update frame virtual void clrtoeol() = 0; void linemove(Dir); void linedel(); // undraw line under cursor static class Menu &editMenu(); bool commandMode() const { return cmdmode; } void commandMode(bool m) { cmdmode = m; } protected: char linemode; bool readonly; static bool compose; static const unsigned char graphics[48]; private: static bool cmdmode; EditorBase(const EditorBase &); EditorBase&operator=(const EditorBase &); int linebits() const; // line drawing bits under cursor int composeChar(int ky); Dir last_dir; };