1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
|
/*
* MultiMail offline mail reader
* most class definitions for the interface
Copyright 1996 Kolossvary Tamas <thomas@tvnet.hu>
Copyright 1997 John Zero <john@graphisoft.hu>
Copyright 1997-2018 William McBrine <wmcbrine@gmail.com>
Distributed under the GNU General Public License, version 3 or later. */
#ifndef INTERFACE_H
#define INTERFACE_H
#include "../mmail/mmail.h"
extern "C" {
#include <curses.h>
#include <signal.h>
}
#if defined(PDCURSES) && (PDC_BUILD < 3100)
# error Please upgrade to PDCurses 3.1 or later
#endif
#if defined(NCURSES_MOUSE_VERSION) || defined(PDCURSES)
# define USE_MOUSE
#endif
/* The following assumes that Ncurses' internal SIGWINCH handler is enabled
if, and only if, the Ncurses version is 5.0 or higher. That's the default;
if your setup is different, you should manually define or undefine
NCURSES_SIGWINCH as appropriate.
*/
#ifdef SIGWINCH
# if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR > 4)
# define NCURSES_SIGWINCH
# endif
# ifndef KEY_RESIZE
# define KEY_RESIZE 0777
# endif
#endif
#include "mmcolor.h"
#include "isoconv.h"
#define MINWIDTH 60
#ifdef VANITY_PLATE
# define MINHINORM 19
# define MINHIEXPERT 17
#else
# define MINHINORM 17
# define MINHIEXPERT 17
#endif
enum statetype {nostate, packetlist, arealist, letterlist, letter,
letter_help, littlearealist, address, tagwin, ansiwin,
ansi_help};
enum searchret {False, True, Abort};
enum lineattr {Hidden, Origin, Tearline, Tagline, Sigline, Quoted, Normal};
enum {s_fulltext = 1, s_headers, s_arealist, s_pktlist};
#if defined(SIGWINCH) && !defined(PDCURSES) && !defined(NCURSES_SIGWINCH)
extern "C" void sigwinchHandler(int);
#endif
#define TAGLINE_LENGTH 76
/* Include Keypad keys for PDCurses */
#ifdef PDCURSES
# define MM_PLUS '+': case PADPLUS
# define MM_MINUS '-': case PADMINUS
# define MM_ENTER '\r': case '\n': case PADENTER
# define MM_SLASH '/': case PADSLASH
# define MM_UP KEY_UP: case KEY_A2
# define MM_DOWN KEY_DOWN: case KEY_C2
# define MM_LEFT KEY_LEFT: case KEY_B1
# define MM_RIGHT KEY_RIGHT: case KEY_B3
# define MM_HOME KEY_HOME: case KEY_A1
# define MM_END KEY_END: case KEY_LL: case KEY_C1
# define MM_PPAGE KEY_PPAGE: case KEY_A3
# define MM_NPAGE KEY_NPAGE: case KEY_C3
# define MM_INS KEY_IC: case PAD0
# define MM_DEL KEY_DC: case PADSTOP
#else
# define MM_PLUS '+'
# define MM_MINUS '-'
# define MM_ENTER '\r': case '\n'
# define MM_SLASH '/'
# define MM_UP KEY_UP
# define MM_DOWN KEY_DOWN
# define MM_LEFT KEY_LEFT
# define MM_RIGHT KEY_RIGHT
# define MM_HOME KEY_HOME
# define MM_END KEY_END: case KEY_LL
# define MM_PPAGE KEY_PPAGE
# define MM_NPAGE KEY_NPAGE
# define MM_INS KEY_IC
# define MM_DEL KEY_DC
#endif
#define MM_BACKSP KEY_BACKSPACE: case 8
#define MM_ESC 27
#define MM_F1 KEY_F(1)
#define MM_F2 KEY_F(2)
#ifdef USE_MOUSE
# define MM_MOUSE KEY_MOUSE
#endif
#ifdef MM_WIDE
# define MM_BOARD ((wchar_t) 0x2591)
#else
# define MM_BOARD (ACS_BOARD)
#endif
class ColorClass : public baseconfig
{
static chtype allcolors[];
static const char *col_names[], *col_intro[], *col_comments[];
static const chtype mapped[];
chtype colorparse(const char *);
void processOne(int, const char *);
const char *configLineOut(int);
const char *findcol(chtype);
const char *decompose(chtype);
public:
void Init();
};
class Win
{
protected:
WINDOW *win;
chtype *buffer, curratt;
public:
Win(int, int, int, chtype);
Win(int, int, int, coltype);
~Win();
void init(int, int, int);
void Clear(chtype);
void Clear(coltype);
void put(int, int, chtype);
void put(int, int, char);
#ifdef MM_WIDE
void put(int, int, wchar_t);
#endif
void put(int, int, const chtype *, int = 0);
int put(int, int, const char *, int = -1);
int attrib(chtype);
int attrib(coltype);
void horizline(int);
void update();
void delay_update();
void wtouch();
void wscroll(int);
void cursor_on();
void cursor_off();
int keypressed();
int inkey();
void boxtitle(coltype, const char *, chtype);
void clreol(int, int);
#ifdef USE_MOUSE
int xstart();
int ystart();
#endif
};
class ShadowedWin : public Win
{
#ifdef USE_SHADOWS
WINDOW *shadow;
#endif
public:
ShadowedWin(int, int, int, coltype, const char * = 0, coltype = C_SBACK);
~ShadowedWin();
void touch();
int getstring(int, int, char *, int, coltype, coltype);
};
class InfoWin : public ShadowedWin
{
Win *info;
public:
char *lineBuf;
InfoWin(int, int, int, coltype, const char * = 0, coltype = C_SBACK,
int = 3, int = 2);
~InfoWin();
void irefresh();
void touch();
void oneline(int, chtype);
void iscrl(int);
#ifdef USE_MOUSE
int xstartinfo();
int ystartinfo();
#endif
};
class ListWindow
{
private:
bool lynxNav; //use Lynx-like navigation?
int oldPos; //position at last Draw()
int oldActive; //active at last Draw()
int oldHigh; //location of highlight bar at last Draw()
void checkPos(int);
chtype setHighlight(chtype);
protected:
InfoWin *list;
int list_max_y, list_max_x, top_offset;
int position; //the first element in the window
int active; //this is the highlited
coltype borderCol;
void Draw(); //refreshes the window
void DrawOne(int, chtype);
void DrawOne(int, coltype);
void DrawAll();
virtual int NumOfItems() = 0;
virtual void oneLine(int) = 0;
virtual searchret oneSearch(int, const char *, int) = 0;
virtual bool extrakeys(int) = 0;
virtual void setFilter(const char *) = 0;
public:
ListWindow();
virtual ~ListWindow();
void Move(int); //scrolloz
void setActive(int);
int getActive();
searchret search(const char *, int);
bool KeyHandle(int);
virtual void Delete() = 0;
virtual void Prev();
virtual void Next();
};
#ifdef VANITY_PLATE
class Welcome
{
ShadowedWin *window;
public:
void MakeActive();
void Delete();
};
#endif
class Person
{
public:
Person *next;
char *name;
net_address netmail_addr;
bool killed;
Person(const char * = 0, const char * = 0);
Person(const char *, net_address &);
~Person();
void setname(const char *);
void dump(FILE *);
};
class AddressBook : public ListWindow
{
Person head, *curr, *highlighted, **people, **living;
const char *addfname;
char *filter;
int NumOfPersons, NumOfActive;
bool NoEnter, inletter;
int NumOfItems();
void oneLine(int);
searchret oneSearch(int, const char *, int);
bool extrakeys(int);
void setFilter(const char *);
void Add(const char *, net_address &);
void GetAddress();
int HeaderLine(ShadowedWin &, char *, int, int, coltype);
int Edit(Person &);
void NewAddress();
void ChangeAddress();
void ReadFile();
void DestroyChain();
void MakeChain();
void ReChain();
void SetLetterThings();
void WriteFile();
void kill();
public:
AddressBook();
~AddressBook();
void MakeActive(bool);
void Delete();
void Init();
};
class tagline
{
public:
tagline(const char * = 0);
tagline *next;
char text[TAGLINE_LENGTH + 1];
bool killed;
};
class TaglineWindow : public ListWindow
{
tagline head, *curr, *highlighted, **taglist, **tagactive;
const char *tagname;
char *filter;
int NumOfTaglines, NumOfActive;
bool nodraw, sorted;
void oneLine(int);
searchret oneSearch(int, const char *, int);
bool extrakeys(int);
void setFilter(const char *);
void kill();
bool ReadFile();
void WriteFile(bool);
void DestroyChain();
void MakeChain();
void RandomTagline();
public:
TaglineWindow();
~TaglineWindow();
void MakeActive();
void Delete();
void EnterTagline(const char * = 0);
void EditTagline();
void Init();
int NumOfItems();
const char *getCurrent();
};
class LittleAreaListWindow : public ListWindow
{
int disp, areanum;
int NumOfItems();
void oneLine(int);
searchret oneSearch(int, const char *, int);
bool extrakeys(int);
void setFilter(const char *);
void Select();
public:
void init();
void MakeActive();
void Delete();
int getArea();
};
class PacketListWindow : public ListWindow
{
class oneDir
{
public:
oneDir *parent;
char *name;
int position, active;
oneDir(const char *, oneDir *);
~oneDir();
};
#ifdef VANITY_PLATE
Welcome welcome;
#endif
file_list *packetList;
oneDir *currDir, *origDir;
#ifdef HAS_HOME
char *home;
#endif
time_t currTime;
int noDirs, noFiles;
bool sorttype;
int NumOfItems();
void oneLine(int);
searchret oneSearch(int, const char *, int);
bool extrakeys(int);
void setFilter(const char *);
void newList();
bool newDir(const char *);
void gotoDir();
void renamePacket();
void killPacket();
void MakeActiveCore();
public:
PacketListWindow();
~PacketListWindow();
void init();
void MakeActive();
void Delete();
void Select();
pktstatus OpenPacket();
bool back();
};
class AreaListWindow : public ListWindow
{
char format[40];
bool hasPers, hasSys;
int NumOfItems();
void oneLine(int);
searchret oneSearch(int, const char *, int);
bool extrakeys(int);
void setFilter(const char *);
public:
void ResetActive();
void MakeActive();
void Delete();
void Select();
void ReDraw();
void FirstUnread();
void Prev();
void Next();
};
class LetterListWindow : public ListWindow
{
char format[50], *topline;
int NumOfItems();
void oneLine(int);
searchret oneSearch(int, const char *, int);
bool extrakeys(int);
void setFilter(const char *);
void listSave();
void setFormat();
void MakeActiveCore();
public:
LetterListWindow();
void ResetActive();
void MakeActive();
void Delete();
void Select();
void FirstUnread();
void Prev();
void Next();
};
class LetterWindow
{
class Line
{
public:
Line *next;
const char *text;
unsigned length;
lineattr attr;
Line();
void out(FILE *);
};
Win *headbar, *header, *text, *statbar;
Line **linelist;
char tagline1[TAGLINE_LENGTH + 1], *To;
int letter_in_chain; //-1 = no letter in chain
int position; //which row is the first in the text window
int NumOfLines;
int y; //height of the window, set by MakeActive
int beepPers;
bool rot13, hidden, lynxNav;
net_address NM;
time_t lasttime;
void lineCount();
void oneLine(int);
void Move(int);
char *netAdd(char *);
int HeaderLine(ShadowedWin &, char *, int, int, coltype);
int EnterHeader(char *, char *, char *, bool &);
void QuoteText(FILE *);
void DestroyChain();
void setToFrom(char, char *, char *);
void forward_header(FILE *, const char *, const char *, const char *,
int, bool);
void EditLetter(bool);
bool SplitLetter(int = 0);
long reconvert(const char *);
void write_header_to_file(FILE *);
void write_to_file(FILE *);
void GetTagline();
bool Previous();
void NextDown();
void MakeChain(int, bool = false);
void MakeChainFixPos();
void DrawFlags();
void UpdateHeader();
void DrawHeader();
void DrawBody();
void DrawStat();
bool EditOriginal();
public:
LetterWindow();
~LetterWindow();
void MakeActive(bool);
void TimeUpdate();
void Delete();
bool Next();
void Draw(bool = false);
void ReDraw();
bool Save(int);
void EnterLetter(int, char);
void StatToggle(int);
net_address &PickNetAddr();
void set_Letter_Params(net_address &, const char *);
void setPos(int);
int getPos();
searchret search(const char *);
void SplitAll(int);
void KeyHandle(int);
};
class HelpWindow
{
Win *menu;
int midpos, endpos, base, items;
void newHelpMenu(const char **, const char **, int);
void h_packetlist();
void h_arealist();
void h_letterlist();
void h_letter(bool);
public:
HelpWindow();
void MakeActive();
void Delete();
void baseNext();
void baseReset();
};
class StringFile
{
FILE *afile;
file_header *fromFile;
letter_body *msgBody, *msgBodyFirst;
const unsigned char *srcStr, *curpos;
public:
void init(file_header *);
void init(letter_body *);
void close();
unsigned char nextchar();
void backup(int);
void reset();
bool anyleft();
};
class AnsiWindow
{
class AnsiLine
{
private:
AnsiLine *prev, *next;
union {
chtype *text;
unsigned char *atext;
};
int length;
chtype att;
bool isasc;
public:
AnsiLine *getprev();
AnsiLine *getnext(bool = false);
AnsiLine(AnsiLine * = 0);
~AnsiLine();
int unpack(chtype *);
void pack(chtype *, size_t);
void show(Win *, int);
void unpacktext(char *);
void remapzero(chtype newatt);
};
static const int ansi_colortable[], pc_colortable[];
bool colorsused[64];
char escparm[256]; //temp copy of ESC sequence parameters
const char *title;
StringFile source;
Win *header, *text, *statbar, *animtext;
AnsiLine *head, *curr, **linelist;
int position; //which row is the first in the window
int NumOfLines;
int x, y; //dimensions of the window
int cpx, cpy, lpy; //ANSI positions
int spx, spy; //stored ANSI positions
int tlen; //maximum X reached
int ccf, ccb, cfl, cbr, crv; //colors and attributes
int oldcolorx, oldcolory;
int baseline; //base for positions in non-anim mode
bool anim; //animate mode?
bool ansiAbort;
#ifdef NCURSES_VERSION
bool useAltCharset;
#endif
chtype *chtmp, attrib; //current attribute
bool isLatin, avtparse, bsvparse, isbsv;
int atparse;
void oneLine(int);
void lineCount();
void DrawBody();
int getparm();
void cls();
void colreset();
chtype colorcore();
void colorset();
void pc_colorset(unsigned char);
void athandle();
void cpylow();
void cpyhigh();
void cpxhigh();
void cpxlow();
void escfig();
void avatar();
void posreset();
void checkpos();
void update(unsigned char);
void ResetChain();
void MakeChain();
void DestroyChain();
void animate();
void statupdate(const char * = 0);
void Save();
public:
void Init();
void set(letter_body *, const char *, bool);
void set(file_header *, const char *, bool);
void MakeActive();
void Delete();
void setPos(int);
int getPos();
searchret search(const char *);
void KeyHandle(int);
};
class Interface
{
#ifdef USE_SHELL
Shell shell;
#endif
#ifdef EXTRAPATH
ExtraPath extrapath;
#endif
PacketListWindow packets;
AddressBook addresses;
HelpWindow helpwindow;
LittleAreaListWindow littleareas;
Win *screen;
ListWindow *currList;
statetype state, prevstate, searchstate;
const char *searchItem, *cmdpktname;
file_header *goodbye;
int Key, searchmode, s_oldpos, width_min, height_min;
bool unsaved_reply, any_read, addrparm, commandline, abortNow,
dontSetAsRead, lynxNav;
#ifdef KEY_RESIZE
bool resized;
void sigwinch();
#endif
void init_colors();
void oldstate(statetype);
void helpreset(statetype);
void newstate(statetype);
void alive();
void screen_init();
const char *pkterrmsg(pktstatus);
void newpacket();
void create_reply_packet();
void save_read();
int ansiCommon();
void searchNext();
void searchSet();
void KeyHandle();
public:
ColorClass colorlist;
AreaListWindow areas;
LetterListWindow letters;
LetterWindow letterwindow;
TaglineWindow taglines;
AnsiWindow ansiwindow;
Interface();
~Interface();
void init();
void main();
int WarningWindow(const char *, const char ** = 0, int = 2);
int savePrompt(const char *, char *);
void nonFatalError(const char *);
void ReportWindow(const char *);
void changestate(statetype);
void redraw();
bool select();
bool back(); //returns true if we have to quit
statetype active();
statetype prevactive();
void addressbook(bool = false);
bool Tagwin();
int ansiLoop(letter_body *, const char *, bool);
int ansiFile(file_header *, const char *, bool);
void ansiList(file_header **, bool);
int areaMenu();
void kill_letter();
void setUnsaved();
void setUnsavedNoAuto();
void setAnyRead();
void setKey(int);
bool dontRead();
bool fromCommandLine(const char *);
};
extern mmail mm;
extern Interface *ui;
extern time_t starttime;
#ifdef USE_MOUSE
extern MEVENT mm_mouse_event;
void mm_mouse_get();
#endif
#endif
|