Viswin interruption working

git-svn-id: svn://10.65.10.50/trunk@15 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-08-17 07:58:50 +00:00
parent da54026c24
commit 260dd9d29f
6 changed files with 6495 additions and 4504 deletions

View File

@ -10,7 +10,6 @@
#endif
#include <utility.h>
#define BLOCKLEN 512
#define INVFLD 255
@ -20,7 +19,8 @@ TFile::TFile(int lenrec, int base)
{
_file = new SecDef;
if (_file == NULL) fatal_box("Can't allocate record file ");
if (_file == NULL)
fatal_box ("Can't allocate record file ");
_file->IOR = NOERR;
_len = lenrec;
_base = base;
@ -29,58 +29,57 @@ TFile::TFile(int lenrec, int base)
_file->name[0] = '\0';
}
TFile ::~TFile ()
{
delete _file;
}
void TFile::open(const char* name, TFilelock lockmode)
void TFile ::
open (const char *name, TFilelock lockmode)
{
COpen (_file, (char *) name, _len, _base, lockmode);
}
bool TFile::verify(const char* name)
bool TFile ::
verify (const char *name)
{
CVerify (_file, (char *) name);
return _file->IOR == NOERR;
}
void TFile::create(const char* name, TRecnotype nrecord)
void TFile ::
create (const char *name, TRecnotype nrecord)
{
CCreate (_file, (char *) name, _len, _base, (nrecord * _len) / BLOCKLEN + 1);
}
void TFile::chsize(const char* name, TRecnotype nrecord)
void TFile ::
chsize (const char *name, TRecnotype nrecord)
{
CChsize (_file, (char *) name, _len, _base, (nrecord * _len) / BLOCKLEN + 1);
}
void TFile::close()
void TFile ::
close ()
{
CClose (_file);
}
void TFile::unlink(const char* name)
void TFile ::
unlink (const char *name)
{
CDelete (_file, (char *) name);
}
void TFile::read(char* record, TRecnotype recnum, TReclock lock)
void TFile ::
read (char *record, TRecnotype recnum, TReclock lock)
{
_file->LenRec = _len;
@ -88,8 +87,8 @@ void TFile::read(char* record, TRecnotype recnum, TReclock lock)
CRead (_file, record, recnum, lock);
}
void TFile::write(char* record, TRecnotype recnum, TReclock lock)
void TFile ::
write (char *record, TRecnotype recnum, TReclock lock)
{
_file->LenRec = _len;
@ -97,15 +96,16 @@ void TFile::write(char* record, TRecnotype recnum, TReclock lock)
CWrite (_file, record, recnum, lock);
}
int TFile::status() const
int TFile ::
status ()
const
{
return _file->IOR;
}
TDir::TDir()
TDir ::
TDir ()
{
_dir = new FileDes;
@ -115,81 +115,86 @@ TDir::TDir()
_num = -1;
}
TDir ::~TDir ()
{
delete _dir;
}
const char* TDir::name() const
const char *TDir ::
name ()
const
{
return _dir->SysName;
}
const char* TDir::des() const
const char *TDir ::des ()
const
{
return _dir->Des;
}
const char* TDir::expr() const
const char *TDir ::expr ()
const
{
return _dir->FCalc;
}
TRecnotype& TDir::eod() const
TRecnotype & TDir ::
eod ()
const
{
return _dir->EOD;
}
TRecnotype& TDir::eox() const
TRecnotype & TDir ::
eox ()
const
{
return _dir->EOX;
}
TRecnotype& TDir::flags() const
TRecnotype & TDir ::
flags ()
const
{
return _dir->Flags;
}
word& TDir::len()
word & TDir ::
len ()
{
return (word &) _dir->LenR;
}
int TDir::status(TDirtype dirop) const
int TDir ::
status (TDirtype dirop)
const
{
return fdir[dirop].IOR;
}
void TDir ::set_len (const UINT16 len)
{
_dir->LenR = len;
}
void TDir::set_eox(const RecNoType eox)
void TDir ::
set_eox (const RecNoType eox)
{
_dir->EOX = eox;
}
void TDir::set(const char * name, const RecNoType eod, const RecNoType flag, const char * des, const char * calc)
void TDir ::
set (const char *name, const RecNoType eod, const RecNoType flag, const char *des, const char *calc)
{
strncpy (_dir->SysName, name, sizeof (_dir->SysName));
_dir->EOD = eod;
@ -198,7 +203,8 @@ void TDir::set(const char * name, const RecNoType eod, const RecNoType flag, con
strncpy (_dir->FCalc, calc, sizeof (_dir->FCalc));
}
void TDir::get(int nfile, TReclock lock, TDirtype dirtype, TDirop op)
void TDir ::
get (int nfile, TReclock lock, TDirtype dirtype, TDirop op)
{
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
@ -210,8 +216,8 @@ void TDir::get(int nfile, TReclock lock, TDirtype dirtype, TDirop op)
_num = nfile;
}
void TDir::put(int nfile, TDirtype dirtype, TDirop op)
void TDir ::
put (int nfile, TDirtype dirtype, TDirop op)
{
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
@ -224,15 +230,16 @@ void TDir::put(int nfile, TDirtype dirtype, TDirop op)
CPutFile (nfile, _dir, _whichdir);
}
void TDir::zero()
void TDir ::
zero ()
{
zerofdes (_dir);
}
int TDir::items(TDirtype dirtype) const
int TDir ::
items (TDirtype dirtype)
const
{
FileDes f;
@ -242,7 +249,8 @@ int TDir::items(TDirtype dirtype) const
return (int) f.EOD;
}
TTrec::TTrec()
TTrec ::
TTrec ()
{
_rec = new RecDes;
@ -252,15 +260,15 @@ TTrec::TTrec()
_num = -1;
}
TTrec ::~TTrec ()
{
delete _rec;
}
int TTrec::compare(const TSortable& a) const
int TTrec ::
compare (const TSortable & a)
const
{
const TTrec & r = (const TTrec &) a;
@ -282,7 +290,8 @@ TTrec& TTrec::operator =(const TTrec& b)
return *this;
}
void TTrec::get(int nfile, TDirtype dirtype)
void TTrec ::
get (int nfile, TDirtype dirtype)
{
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
@ -291,8 +300,8 @@ void TTrec::get(int nfile, TDirtype dirtype)
_num = nfile;
}
void TTrec::put(int nfile, TDirtype dirtype)
void TTrec ::
put (int nfile, TDirtype dirtype)
{
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
@ -302,29 +311,31 @@ void TTrec::put(int nfile, TDirtype dirtype)
CPutRec (nfile, _rec, _whichdir);
}
void TTrec::zero()
void TTrec ::
zero ()
{
zerordes (_rec);
}
int TTrec::status(TDirtype dirop) const
int TTrec ::
status (TDirtype dirop)
const
{
return rdir[dirop].IOR;
}
int TTrec::field(const char* name) const
int TTrec ::field (const char *name)
const
{
return findfld (_rec, (char *) name);
}
const char* TTrec::fielddef(int fld) const
const char *TTrec ::fielddef (int fld)
const
{
sprintf (_files_tmp_string, "%s|%d|%d|%d", _rec->Fd[fld].Name,
@ -333,7 +344,8 @@ const char* TTrec::fielddef(int fld) const
return _files_tmp_string;
}
const char* TTrec::keydef(int key) const
const char *TTrec ::keydef (int key)
const
{
TFixed_string s (_files_tmp_string, 128);
@ -344,19 +356,23 @@ const char* TTrec::keydef(int key) const
const bool upper = _rec->Ky[key].FieldSeq[j] > MaxFields;
const int nfld = _rec->Ky[key].FieldSeq[j] - (upper ? MaxFields : 0);
if (j) s << "+";
if (upper) s << "UPPER(";
if (j)
s << "+";
if (upper)
s << "UPPER(";
s << _rec->Fd[nfld].Name;
if (_rec->Ky[key].FromCh[j] < INVFLD)
s << format ("[%d,%d]", _rec->Ky[key].FromCh[j] + 1,
_rec->Ky[key].ToCh[j] + 1);
if (upper) s << ")";
if (upper)
s << ")";
}
s << (_rec->Ky[key].DupKeys ? "|X" : "| ");
return (const char *) s;
}
void TTrec::update_fielddef(int nfld, const char* desc)
void TTrec ::
update_fielddef (int nfld, const char *desc)
{
TToken_string s (desc);
@ -366,8 +382,8 @@ void TTrec::update_fielddef(int nfld, const char* desc)
_rec->Fd[nfld].Dec = s.get_int ();
}
void TTrec::update_keydef(int key, const char* desc)
void TTrec ::
update_keydef (int key, const char *desc)
{
TExpression expr ("", _strexpr);
@ -390,7 +406,8 @@ void TTrec::update_keydef(int key, const char* desc)
const char *s = inst.string ();
for (int i = 0; i < _rec->NFields; i++)
if (strcmp(_rec->Fd[i].Name, s) == 0) break;
if (strcmp (_rec->Fd[i].Name, s) == 0)
break;
_rec->Ky[key].FieldSeq[n] = i;
_rec->Ky[key].FromCh[n] = INVFLD;
@ -399,15 +416,15 @@ void TTrec::update_keydef(int key, const char* desc)
sym = inst.getsym ();
if (sym == _upper)
_rec->Ky[key].FieldSeq[n] += MaxFields;
else
if (sym == _number)
else if (sym == _number)
{
_rec->Ky[key].FromCh[n] = inst.number ().integer () - 1;
inst = c.step ();
_rec->Ky[key].ToCh[n] = _rec->Ky[key].FromCh[n] + inst.number ().integer () - 1;
inst = c.step ();
}
else c.backtrace();
else
c.backtrace ();
n++;
}
}
@ -415,7 +432,9 @@ void TTrec::update_keydef(int key, const char* desc)
}
}
void TTrec::print_on(ostream& out) const
void TTrec ::
print_on (ostream & out)
const
{
out << num () << '\n';
@ -438,8 +457,8 @@ void TTrec::print_on(ostream& out) const
}
}
void TTrec::read_from(istream& in)
void TTrec ::
read_from (istream & in)
{
int ln;
@ -470,5 +489,3 @@ void TTrec::read_from(istream& in)
}
rehash ();
}

View File

@ -18,9 +18,13 @@ const short FIRST_FIELD = 101;
class TSpreadsheet:public TWindow
{
enum { ITF_CID = 0, LIST_CID = 1 };
enum
{
ITF_CID = 0, LIST_CID = 1
};
TArray _str; // Array di TToken_strings
TBit_array _column_disabled;
TArray _disabled; // Array di TBit_array
@ -57,7 +61,10 @@ public:
void update (int row);
TToken_string & row (int n);
TArray& rows_array() const { return (TArray&)_str; }
TArray & rows_array () const
{
return (TArray &) _str;
}
int add (TToken_string &);
int insert (int rec);
bool destroy (int rec = -1);
@ -66,13 +73,30 @@ public:
void enable_cell (int row, int column, bool on = TRUE);
bool cell_disabled (int row, int column) const;
TMask& mask() { return _mask; }
int items() const { return _str.items(); }
int columns() const { return _columns; }
bool dirty() const { return _dirty; }
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
TMask & mask ()
{
return _mask;
}
int items () const
{
return _str.items ();
}
int columns () const
{
return _columns;
}
bool dirty () const
{
return _dirty;
}
void set_notify (SPREADSHEET_NOTIFY n)
{
_notify = n;
}
void set_dirty(bool spork = TRUE) { _dirty = spork; }
void set_dirty (bool spork = TRUE)
{_dirty = spork;
}
TSpreadsheet (short x, short y, short dx, short dy, const char *maskname, int maskno,
const char *head, WINDOW parent);
@ -125,7 +149,9 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
{
w = atoi (at + 1);
*at = '\0';
} else w = strlen(h);
}
else
w = strlen (h);
width[i] = w + 1;
@ -188,7 +214,8 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL;
if (f->class_id () == CLASS_REAL_FIELD) flags |= XI_ATR_RJUST;
if (f->active ())flags |= XI_ATR_ENABLED;
else _column_disabled.set(i);
else
_column_disabled.set (i);
coldef = xi_add_column_def (listdef, cid,
flags, cid, w, width[i], (char *) h);
@ -215,7 +242,6 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
_list = xi_get_obj (itf, LIST_CID);
}
// Converts a row number in the correspondig record number
int TSpreadsheet ::row2rec (int row)
{
@ -233,7 +259,6 @@ int TSpreadsheet::row2rec(int row)
return (int) rec[row];
}
// Converts a row number in the correspondig record number
int TSpreadsheet ::rec2row (int record)
{
@ -286,7 +311,6 @@ void TSpreadsheet::set_focus_cell(int riga, int colonna)
xi_set_focus (&cell);
}
int TSpreadsheet ::insert (int rec)
{
const bool ok = notify (rec, K_INS);
@ -302,7 +326,6 @@ int TSpreadsheet::insert(int rec)
return r;
}
bool TSpreadsheet ::destroy (int rec)
{
bool ok = TRUE;
@ -324,7 +347,6 @@ bool TSpreadsheet::destroy(int rec)
return ok;
}
void TSpreadsheet ::update (int row)
{
if (row < 0)
@ -337,7 +359,6 @@ void TSpreadsheet::update(int row)
update_rec (row);
}
void TSpreadsheet ::xiev_handler (XI_OBJ * itf, XI_EVENT * xiev)
{
TSpreadsheet * es = (TSpreadsheet *) xi_get_app_data (itf);
@ -345,7 +366,6 @@ void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev)
es->list_handler (xiev);
}
// Certified 75%
void TSpreadsheet ::list_handler (XI_EVENT * xiev)
{
@ -411,7 +431,9 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
if (cell_disabled (rec, col))
xiev->v.cell_request.back_color = MASK_BACK_COLOR;
}
} else src = format("%d", rec+1);
}
else
src = format ("%d", rec + 1);
const int len = xiev->v.cell_request.len;
char *dst = xiev->v.cell_request.s;
@ -445,7 +467,8 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
check_enabled = TRUE; // Enable checks
xi_set_focus (xiev->v.xi_obj); // Restore focus to cell
}
} else
}
else
if (xiev->v.xi_obj->type == XIT_LIST)
insert (-1);
break;
@ -517,7 +540,8 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
case XIE_OFF_CELL:
if (edit_field && check_enabled)
{
TMask_field* c = edit_field; // Save field, it could turn out to be NULL on error
TMask_field * c = edit_field; // Save field, it could turn out to
// be NULL on error
const TString80 old (c->get ()); // Save old value on mask
const TString80 nuo (c->picture_data (xi_get_text (xiev->v.xi_obj, NULL, -1), TRUE));
if (old != nuo)
@ -674,12 +698,26 @@ public:
TSpreadsheet (short x, short y, short dx, short dy, const char *maskname, int maskno,
const char *head, WINDOW parent);
TArray& rows_array() const { return data(); }
TArray & rows_array () const
{
return data ();
}
TMask& mask() { return _mask; }
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
void set_dirty(bool spork = TRUE) { _dirty = spork;}
bool dirty() const { return _dirty;}
TMask & mask ()
{
return _mask;
}
void set_notify (SPREADSHEET_NOTIFY n)
{
_notify = n;
}
void set_dirty (bool spork = TRUE)
{_dirty = spork;
}
bool dirty ()const
{
return _dirty;
}
void enable_column (int col, bool on);
void enable_cell (int row, int column, bool on = TRUE);
@ -691,7 +729,8 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
const char *head, WINDOW parent)
:TArray_sheet (x, y, dx, dy, maskname, head, 0, parent),
_mask (maskname, NO_MODE, maskno), _notify (NULL)
{}
{
}
bool TSpreadsheet ::on_key (KEY k)
{
@ -702,18 +741,24 @@ bool TSpreadsheet::on_key(KEY k)
mask ().send_key (k, 0);
return TRUE;
case K_ENTER: // Selezione riga per editing
if (items () < 1) k = K_INS; // Se vuoto crea riga da editare
case K_INS:
case 'A': // Aggiunge dopo
case 'I': // Aggiunge prima
{
int n = (int)selected ();
if (k != K_ENTER)
{
if (k == K_INS) n = items(); else // Aggiunge alla fine
if (k == K_INS) n = items ();
else // Aggiunge alla fine
if (k == 'A') n++;
if (n < 0) n = 0; else
if (n < 0) n = 0;
else
if (n > items ())n = items (); // Controlla range n
if (notify (n, K_INS) == FALSE) // Chiede l'ok alla applicazione
@ -750,7 +795,6 @@ TMask_field* TSpreadsheet::field(short id) const
return &_mask.fld (pos);
}
void TSpreadsheet ::mask2str (int riga)
{
TToken_string & r = row (riga);
@ -766,7 +810,6 @@ void TSpreadsheet::mask2str(int riga)
#endif
}
// Certified 50%
void TSpreadsheet ::enable_cell (int row, int column, bool on)
{
@ -796,13 +839,11 @@ void TSpreadsheet::enable_cell(int row, int column, bool on)
}
}
void TSpreadsheet ::enable_column (int col, bool on)
{
_column_disabled.set (col, !on);
}
// Certified 99%
bool TSpreadsheet ::cell_disabled (int row, int column) const
{
@ -811,7 +852,6 @@ bool TSpreadsheet::cell_disabled(int row, int column) const
return (*ba)[column];
}
// Certified 75%
void TSpreadsheet ::str2mask (int riga)
{
@ -853,14 +893,12 @@ void TSpreadsheet::str2mask(int riga)
_mask.set_caption (format ("Riga %d", riga + 1));
}
// Certified 100%
bool TSpreadsheet ::notify (int n, KEY k)
{
return _notify ? _notify (n, k) : TRUE;
}
// Certified 99%
KEY TSpreadsheet ::edit (int n)
{
@ -870,7 +908,8 @@ KEY TSpreadsheet::edit(int n)
if (k == K_ENTER)
{
mask2str (n);
} else
}
else
if (k == K_DEL)
{
const bool ok = notify (n, K_DEL); // Notifica intenzione di cancellare
@ -890,7 +929,8 @@ KEY TSpreadsheet::edit(int n)
// Certified 100%
TSheet_field ::TSheet_field (TMask * m)
: TMask_field (m), _sheet (NULL)
{}
{
}
// Certified 100%
word TSheet_field ::class_id ()const
@ -918,7 +958,6 @@ void TSheet_field::parse_head(TScanner& scanner)
if (_size == 0) _size = -1;
}
// Certified 100%
bool TSheet_field ::parse_item (TScanner & scanner)
{
@ -942,14 +981,12 @@ void TSheet_field::create(WINDOW parent)
show_window (_win, showed ());
}
// Certified 100%
TArray & TSheet_field ::rows_array ()const
{
return _sheet->rows_array ();
}
// Certified 100%
// Ritorna l'indice della prima riga vuota dello sheet
int TSheet_field ::first_empty ()const
@ -961,7 +998,6 @@ int TSheet_field::first_empty() const
return n;
}
TToken_string & TSheet_field ::row (int n)
{
const int max = _sheet->items ();
@ -973,7 +1009,6 @@ TToken_string& TSheet_field::row(int n)
return _sheet->row (n);
}
void TSheet_field ::force_update (int r)
{
#if XVTWS == WMWS
@ -983,7 +1018,6 @@ void TSheet_field::force_update(int r)
#endif
}
void TSheet_field ::set_window_data (const char *)
{
_sheet->set_dirty (FALSE);
@ -995,37 +1029,31 @@ void TSheet_field::set_field_data(const char*)
set_dirty (_sheet->dirty ());
}
int TSheet_field ::items ()const
{
return (int)_sheet->items ();
}
void TSheet_field ::set_notify (SPREADSHEET_NOTIFY n)
{
_sheet->set_notify (n);
}
void TSheet_field ::enable_column (int column, bool on)
{
_sheet->enable_column (column, on);
}
void TSheet_field ::enable_cell (int row, int column, bool on)
{
_sheet->enable_cell (row, column, on);
}
TMask & TSheet_field ::sheet_mask ()const
{
return _sheet->mask ();
}
bool TSheet_field ::on_key (KEY k)
{
if (k == K_TAB)

View File

@ -1,4 +1,4 @@
// $Id: printapp.cpp,v 1.1.1.1 1994-08-12 10:51:57 alex Exp $
// $Id: printapp.cpp,v 1.2 1994-08-17 07:58:45 villa Exp $
#include <ctype.h>
#include <stdarg.h>
@ -41,11 +41,18 @@ class _Transfield : public TObject
TString _from, // "from" value
_to, // "to" value
_fn; // field name
int _lognum; // logical number
public:
_Transfield (int l, const char *fn, const char *from, const char *to):
_from (3), _to (20), _fn (10)
{ _lognum = l; _from = from; _to = to; _fn = fn; }
{
_lognum = l;
_from = from;
_to = to;
_fn = fn;
}
};
class _Token:public TObject
@ -54,11 +61,25 @@ friend class TPrint_application;
int _tag;
int _row;
public:
int tag() { return _tag; }
int row() { return _row; }
void tag(int t) { _tag = t; }
void row(int r) { _row = r; }
virtual ~_Token() {}
int tag ()
{
return _tag;
}
int row ()
{
return _row;
}
void tag (int t)
{
_tag = t;
}
void row (int r)
{
_row = r;
}
virtual ~ _Token ()
{
}
};
class _PrintfTok:public _Token
@ -68,8 +89,14 @@ friend class TPrint_application;
TString _val;
public:
_PrintfTok (int rw, const char *val):_val (0)
{ tag(0); row(rw); _val = val; }
virtual ~_PrintfTok() {}
{
tag (0);
row (rw);
_val = val;
}
virtual ~ _PrintfTok ()
{
}
};
class _FieldTok:public _Token
@ -79,16 +106,25 @@ friend class TPrint_application;
int _size, _dec;
char _align;
TString _fld; // field description
word _flags; // all you need to know
public:
_FieldTok (int rw, char *fld, word flags, char align = 'l',
int size = -1, int dec = -1):
_fld (20)
{
tag(1); row(rw); _fld = (const char*)fld; _flags = flags;
_size = size, _align = align; _dec = dec; delete fld;
tag (1);
row (rw);
_fld = (const char *) fld;
_flags = flags;
_size = size, _align = align;
_dec = dec;
delete fld;
}
virtual ~ _FieldTok ()
{
}
virtual ~_FieldTok() {}
};
class _PrintfRef:public _Token
@ -102,23 +138,33 @@ friend class TPrint_application;
public:
_PrintfRef (int rw, const char *fmt, char type, void *what):_fmt (1)
{
tag(2); row(rw); _type = type; _what = what; _fmt = fmt;
tag (2);
row (rw);
_type = type;
_what = what;
_fmt = fmt;
_fmt[0] = '%';
}
virtual ~_PrintfRef() {}
virtual ~ _PrintfRef ()
{
}
};
void TPrint_application::_reset_tree(link_item* head)
void TPrint_application ::
_reset_tree (link_item * head)
{
if (head)
{
if (head->_brother) _reset_tree(head->_brother);
if (head->_son) _reset_tree(head->_son);
if (head->_brother)
_reset_tree (head->_brother);
if (head->_son)
_reset_tree (head->_son);
delete head;
}
}
link_item* TPrint_application::_look_print_node(link_item* head, int logicnum)
link_item *TPrint_application ::
_look_print_node (link_item * head, int logicnum)
{
// look for <from> node to attach to
// since it reflects a relation, it won't have more than
@ -126,7 +172,8 @@ link_item* TPrint_application::_look_print_node(link_item* head, int logicnum)
link_item *s;
while (head)
{
if (head->_logicnum == logicnum) return head;
if (head->_logicnum == logicnum)
return head;
else if (head->_son)
if ((s = _look_print_node (head->_son, logicnum)) != NULL)
return s;
@ -135,12 +182,14 @@ link_item* TPrint_application::_look_print_node(link_item* head, int logicnum)
return NULL;
}
void TPrint_application::add_file(const char* tab, int from)
void TPrint_application ::
add_file (const char *tab, int from)
{
add_file (TTable ::name2log (tab), from);
}
void TPrint_application::add_file(int file, int from)
void TPrint_application ::
add_file (int file, int from)
{
link_item *nw = new link_item (file);
if (_pr_tree == NULL)
@ -159,10 +208,12 @@ void TPrint_application::add_file(int file, int from)
if (fr->_son)
{
fr = fr->_son;
while (fr->_brother) fr = fr->_brother;
while (fr->_brother)
fr = fr->_brother;
fr->_brother = nw;
}
else fr->_son = nw;
else
fr->_son = nw;
}
// ---------------------------------------------------------------
@ -170,21 +221,29 @@ void TPrint_application::add_file(int file, int from)
static char tb[120];
int TPrint_application::enable_link (const char* descr, char fg, char bg)
int TPrint_application ::
enable_link (const char *descr, char fg, char bg)
{
TToken_string *tt = new TToken_string (30);
char b[2]; b[1] = '\0';
tt->add(descr); b[0] = fg; tt->add(b); b[0] = bg; tt->add(b);
char b[2];
b[1] = '\0';
tt->add (descr);
b[0] = fg;
tt->add (b);
b[0] = bg;
tt->add (b);
printer ().links ().add (tt);
return printer ().links ().items () - 1;
}
void TPrint_application::disable_link(char fg, char bg)
void TPrint_application ::
disable_link (char fg, char bg)
{
for (int i = 0; i < printer ().links ().items (); i++)
{
TToken_string & t = (TToken_string &) printer ().links ()[i];
char f = *(t.get(1)); char b = *(t.get(2));
char f = *(t.get (1));
char b = *(t.get (2));
if (f == fg && b == bg)
{
printer ().links ().add (NULL, i);
@ -194,19 +253,21 @@ void TPrint_application::disable_link(char fg, char bg)
}
}
void TPrint_application::set_multiple_link(bool on)
void TPrint_application ::
set_multiple_link (bool on)
{
printer ().setmultiplelink (on);
}
void TPrint_application::_pp_link(int id, const char* text)
void TPrint_application ::
_pp_link (int id, const char *text)
{
TPrint_application *prapp = (TPrint_application *) MainApp ();
prapp->process_link (id, text);
}
void TPrint_application::_pp_header(TPrinter&)
void TPrint_application ::
_pp_header (TPrinter &)
{
TPrint_application *prapp = (TPrint_application *) MainApp ();
@ -221,8 +282,8 @@ void TPrint_application::_pp_header(TPrinter&)
new TPrintrow ((TPrintrow &) (prapp->_header)[i]));
}
void TPrint_application::_pp_footer(TPrinter&)
void TPrint_application ::
_pp_footer (TPrinter &)
{
TPrint_application *prapp = (TPrint_application *) MainApp ();
@ -235,15 +296,14 @@ void TPrint_application::_pp_footer(TPrinter&)
new TPrintrow ((TPrintrow &) (prapp->_footer)[i]));
}
void TPrint_application::set_background(const char* bgdesc)
void TPrint_application ::
set_background (const char *bgdesc)
{
printer ().setbackground (bgdesc);
}
const char* FLD(int lognum, const char* f, int from, int to)
const char *
FLD (int lognum, const char *f, int from, int to)
{
sprintf (tb, "%c|%d|%s|%d|%d", 'n', lognum, f, from, to);
char *p = new char[strlen (tb) + 1];
@ -251,7 +311,8 @@ const char* FLD(int lognum, const char* f, int from, int to)
return p;
}
const char* FLD(int lognum, const char* f, const char* picture)
const char *
FLD (int lognum, const char *f, const char *picture)
{
sprintf (tb, "%c|%d|%s|%s", 'p', lognum, f, picture);
char *p = new char[strlen (tb) + 1];
@ -259,7 +320,8 @@ const char* FLD(int lognum, const char* f, const char* picture)
return p;
}
const char* FLD(const char* tabname, const char* f, int from, int to)
const char *
FLD (const char *tabname, const char *f, int from, int to)
{
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
int lognum = TTable ::name2log (tabname);
@ -269,8 +331,8 @@ const char* FLD(const char* tabname, const char* f, int from, int to)
return p;
}
const char* FLD(const char* tabname, const char* f, const char* picture)
const char *
FLD (const char *tabname, const char *f, const char *picture)
{
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
int lognum = TTable ::name2log (tabname);
@ -280,13 +342,22 @@ const char* FLD(const char* tabname, const char* f, const char* picture)
return p;
}
TString & fill_str (TString & t, char f)
{
for (int kk = t.len () - 1; kk >= 0; kk--)
{ if (t[kk] == ' ') t[kk] = f; else break; }
{
if (t[kk] == ' ')
t[kk] = f;
else
break;
}
for (kk = 0; kk < t.len (); kk++)
{ if (t[kk] == ' ') t[kk] = f; else break; }
{
if (t[kk] == ' ')
t[kk] = f;
else
break;
}
return t;
}
@ -299,27 +370,36 @@ TString& fill_str(TString& t, char f)
// printer().setlinkdescr(descr);
// }
void TPrint_application::select_cursor(int c)
void TPrint_application ::
select_cursor (int c)
{
if (c == -1) _cur = NULL;
else _cur = (TCursor*) &_cursors[c];
if (c == -1)
_cur = NULL;
else
_cur = (TCursor *) & _cursors[c];
}
TCursor* TPrint_application::get_cursor(int c)
TCursor *TPrint_application ::
get_cursor (int c)
{
if (c == -1) return NULL;
else return (TCursor*) &_cursors[c];
if (c == -1)
return NULL;
else
return (TCursor *) & _cursors[c];
}
int TPrint_application::add_cursor(TCursor* c)
int TPrint_application ::
add_cursor (TCursor * c)
{
if (c == NULL) return -1;
if (c == NULL)
return -1;
_cursors.add (c);
_cur = c;
return _cursors.items () - 1;
}
void TPrint_application::reset_row(int r)
void TPrint_application ::
reset_row (int r)
{
r--;
int tmp = _rows.items ();
@ -337,14 +417,16 @@ void TPrint_application::reset_row(int r)
_maxrow--;
}
void TPrint_application::reset_print()
void TPrint_application ::
reset_print ()
{
_rows.destroy ();
_maxrow = 0;
_print_defined = FALSE;
}
void TPrint_application::set_header(int r, const char* fmt, ...)
void TPrint_application ::
set_header (int r, const char *fmt,...)
{
CHECK (r >= 1, "Header rows start at 1");
va_list vl;
@ -361,7 +443,8 @@ void TPrint_application::set_header(int r, const char* fmt, ...)
pp->put (__tmp_string);
}
void TPrint_application::set_footer(int r, const char* fmt, ...)
void TPrint_application ::
set_footer (int r, const char *fmt,...)
{
CHECK (r >= 1, "Footer rows start at 1");
va_list vl;
@ -377,27 +460,33 @@ void TPrint_application::set_footer(int r, const char* fmt, ...)
pp->put (__tmp_string);
}
void TPrint_application::reset_header()
void TPrint_application ::
reset_header ()
{
_header.destroy ();
printer ().resetheader ();
}
void TPrint_application::reset_footer()
void TPrint_application ::
reset_footer ()
{
_footer.destroy ();
printer ().resetfooter ();
}
void TPrint_application::fill_page(int from)
void TPrint_application ::
fill_page (int from)
{
from--;
for (int i = (from == -1 ? _maxrow : from); i <= printer ().formlen (); i++)
{ reset_row(i); set_row(i,""); }
{
reset_row (i);
set_row (i, "");
}
}
void TPrint_application::set_row(int r, const char* frmt, ...)
void TPrint_application ::
set_row (int r, const char *frmt,...)
{
CHECK (r >= 1, "Print rows start at 1");
@ -418,7 +507,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
_print_defined = TRUE;
_currow = r;
if (_currow > _maxrow) _maxrow = _currow;
if (_currow > _maxrow)
_maxrow = _currow;
va_list params;
va_start (params, frmt);
@ -438,7 +528,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
ch = *fmt++;
if (isdigit (ch))
{
int i = 0; digbuf[i++] = ch;
int i = 0;
digbuf[i++] = ch;
while (isdigit (ch = *fmt++))
digbuf[i++] = ch;
digbuf[i] = '\0';
@ -447,7 +538,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
if (ch == '.')
{
// decimal size follows
i = 0; digbuf[i++] = ch;
i = 0;
digbuf[i++] = ch;
while (isdigit (ch = *fmt++))
digbuf[i] = ch;
digbuf[i] = '\0';
@ -573,20 +665,29 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
else
{
// read format
t << ccc; bool islong = FALSE;
t << ccc;
bool islong = FALSE;
while (strchr (printf_types, ch) == NULL)
{
t << ch;
if (ch == 'l') islong = TRUE;
if (ch == 'l')
islong = TRUE;
ch = *fmt++;
if (ch == '\0')
fatal_box ("sorry, zer's samzing vruong"
" uitz ioar format.");
}
if (isupper(ch)) { ch = tolower(ch); fill = ' '; }
if (ch == 't') t << 's';
else if (ch == 'r') t << 't';
else t << ch;
if (isupper (ch))
{
ch = tolower (ch);
fill = ' ';
}
if (ch == 't')
t << 's';
else if (ch == 'r')
t << 't';
else
t << ch;
if (ccc == '%')
{
TString q (60);
@ -615,10 +716,12 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
q.format (t, va_arg (params, char *));
break;
case 't': // TString
q.format (t, (const char *)
(TString) * ((va_arg (params, TString *))));
break;
case 'r': // Real
{
real *rrr = va_arg (params, real *);
if (t.len () == 2 && *_picture)
@ -630,7 +733,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
else
{
char *fff = (char *) ((const char *) t);
// dsprintf(__tmp_string, fff, (DEC*)(*rrr));
// dsprintf(__tmp_string, fff,
// (DEC*)(*rrr));
dsprintf (__tmp_string, fff, rrr->ptr ());
q = __tmp_string;
}
@ -641,7 +745,8 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
default:
break;
}
if (fill != ' ') q = fill_str(q,fill);
if (fill != ' ')
q = fill_str (q, fill);
fill = _fillchar;
_rows.add (new _PrintfTok (_currow, q));
}
@ -652,11 +757,13 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
}
break;
case '\n': // ignore
break;
default:
// add to string
strbuf[strind++] = ch;
if (!ch) fmt--;
if (!ch)
fmt--;
break;
}
}
@ -670,13 +777,15 @@ void TPrint_application::set_row(int r, const char* frmt, ...)
va_end (params);
}
void TPrint_application::set_translation(int lognum, const char* field,
void TPrint_application ::
set_translation (int lognum, const char *field,
const char *from, const char *to)
{
_transtab.add (new _Transfield (lognum, field, from, to));
}
void TPrint_application::print()
void TPrint_application ::
print ()
{
// open printer if needed
if (!(printer ().isopen ()))
@ -687,7 +796,8 @@ void TPrint_application::print()
// pre and post process do everything
if (_cur == NULL)
{
int cnt = 0; bool ok = TRUE;
int cnt = 0;
bool ok = TRUE;
do
{
if (preprocess_print (0, cnt))
@ -735,7 +845,8 @@ void TPrint_application::print()
postclose_print ();
}
bool TPrint_application::print_tree(link_item* head)
bool TPrint_application ::
print_tree (link_item * head)
{
bool go = TRUE;
while (head)
@ -774,22 +885,24 @@ bool TPrint_application::print_tree(link_item* head)
while (go && postprocess_print (head->_logicnum, head->_cnt++)
== REPEAT_PAGE);
}
if (!go) break;
if (!go)
break;
go = TRUE;
head = head->_brother;
}
return go;
}
bool TPrint_application::print_one(int file)
bool TPrint_application ::
print_one (int file)
{
int i = 0;
if (_prind && _prind->iscancelled())
if ((_prind && _prind->iscancelled ()) || printer ().frozen ())
return FALSE;
if (!_print_defined) return TRUE;
if (!_print_defined)
return TRUE;
if (_prind && file == _pr_tree->_logicnum)
_prind->addstatus (1);
@ -808,7 +921,9 @@ bool TPrint_application::print_one(int file)
for (int j = 0; j < _rows.items (); j++)
{
_Token *t = (_Token *) & (_rows[j]);
if (!t) continue; // should not happen
if (!t)
continue; // should not happen
if (t->row () == i)
{
char pic[36], fn[17];
@ -895,7 +1010,8 @@ bool TPrint_application::print_one(int file)
}
if (i == _transtab.items ())
toprint = "";
else toprint = tr->_to;
else
toprint = tr->_to;
}
else if (ft->_flags & DATE_FLAG)
{
@ -929,7 +1045,8 @@ bool TPrint_application::print_one(int file)
toprint = r.string (pict);
else if (ft->_flags & DEC_FLAG)
toprint = r.string (ft->_size, ft->_dec);
else toprint = r.string();
else
toprint = r.string ();
if (r.is_zero () && !_print_zero)
toprint.fill (' ');
@ -1060,7 +1177,8 @@ bool TPrint_application::print_one(int file)
return i == _maxrow + 1;
}
bool TPrint_application::menu(MENU_TAG m)
bool TPrint_application ::
menu (MENU_TAG m)
{
// funziona da se' fino a 20 voci della menubar
if (m >= BAR_ITEM (1) && m <= BAR_ITEM (20))
@ -1073,7 +1191,8 @@ bool TPrint_application::menu(MENU_TAG m)
return !xvt_test_menu_tag (BAR_ITEM (2));
}
bool TPrint_application::create()
bool TPrint_application ::
create ()
{
TApplication ::create ();
printer ().setfooterhandler (_pp_footer);
@ -1084,14 +1203,16 @@ bool TPrint_application::create()
return TRUE;
}
bool TPrint_application::destroy()
bool TPrint_application ::
destroy ()
{
user_destroy ();
TApplication ::destroy ();
return TRUE;
}
void TPrint_application::do_print(int n)
void TPrint_application ::
do_print (int n)
{
while (set_print (n))
{
@ -1100,22 +1221,26 @@ void TPrint_application::do_print(int n)
}
}
void TPrint_application::enable_print_menu()
void TPrint_application ::
enable_print_menu ()
{
enable_menu_item (M_FILE_PRINT, TRUE);
}
void TPrint_application::disable_print_menu()
void TPrint_application ::
disable_print_menu ()
{
enable_menu_item (M_FILE_PRINT, FALSE);
}
void TPrint_application::enable_setprint_menu()
void TPrint_application ::
enable_setprint_menu ()
{
enable_menu_item (BAR_ITEM (1), TRUE);
}
void TPrint_application::disable_setprint_menu()
void TPrint_application ::
disable_setprint_menu ()
{
enable_menu_item (BAR_ITEM (1), FALSE);
}
@ -1143,7 +1268,6 @@ TPrint_application::TPrint_application() : TApplication(), _transtab(10),
_last_choice = BAR_ITEM (1);
}
TPrint_application ::~TPrint_application ()
{
reset_files ();

File diff suppressed because it is too large Load Diff

View File

@ -10,47 +10,74 @@ public:
// TArray _spots; // tokenstrings
char _bg, _fg;
_HotSpot(char fg, char bg) { _fg = fg; _bg = bg; }
virtual ~_HotSpot() {}
_HotSpot (char fg, char bg)
{
_fg = fg;
_bg = bg;
}
virtual ~ _HotSpot ()
{
}
};
void TTextfile::set_hotspots(char fg, char bg)
void TTextfile ::
set_hotspots (char fg, char bg)
{
_HotSpot *hp = new _HotSpot (fg, bg);
_hotspots.add (hp);
}
style TTextfile::_trans_style(char ch)
style TTextfile ::
_trans_style (char ch)
{
switch (ch)
{
case 'r': return normal; break;
case 'i': return italic; break;
case 'b': return bold; break;
case 'u': return underlined; break;
case 'o': return overstrike; break;
case 'k': return smallcaps; break;
default: return normal; break;
case 'r':
return normal;
break;
case 'i':
return italic;
break;
case 'b':
return bold;
break;
case 'u':
return underlined;
break;
case 'o':
return overstrike;
break;
case 'k':
return smallcaps;
break;
default:
return normal;
break;
}
}
void TTextfile::_read_page(long n)
void TTextfile ::
_read_page (long n)
{
switch (_direction)
{
case down:
_page_start = n; break;
_page_start = n;
break;
case up:
_page_start = n + _page_size; break;
_page_start = n + _page_size;
break;
case updown:
_page_start = n - (_page_size/2l); break;
_page_start = n - (_page_size / 2l);
break;
}
if (_page_start < 0l) _page_start = 0l;
if ((_page_start + _page_size) > _lines) _page_end = _lines -1;
else _page_end = _page_start + _page_size - 1;
if (_page_start < 0l)
_page_start = 0l;
if ((_page_start + _page_size) > _lines)
_page_end = _lines - 1;
else
_page_end = _page_start + _page_size - 1;
// zap hotspots
_spots.destroy ();
@ -72,8 +99,8 @@ void TTextfile::_read_page(long n)
TString hcol (6);
// find hotspots and compile list
int len = 0; const char* cp;
int len = 0;
const char *cp;
read_line (i, 0, FALSE);
while (cp = piece ())
{
@ -84,7 +111,11 @@ void TTextfile::_read_page(long n)
{
TToken_string *tts = new TToken_string (50);
tts->add (i); // line number
tts->add(len); tts->add(len + (int)strlen(cp) ); tts->add(cp); tts->add(z);
tts->add (len);
tts->add (len + (int) strlen (cp));
tts->add (cp);
tts->add (z);
_spots.add (tts);
break;
}
@ -94,18 +125,22 @@ void TTextfile::_read_page(long n)
}
}
void TTextfile::read_line(long n, long pos, bool pg)
void TTextfile ::
read_line (long n, long pos, bool pg)
{
CHECK (_isopen, "Attempt operation on closed file");
CHECKD (n >= 0 && n < _lines, "Line not present", n);
if (pg && !_in_page(n)) _read_page(n);
if (pg && !_in_page (n))
_read_page (n);
TString *tp = (TString *) _page.objptr (int (n - _page_start));
if (tp == NULL) return;
if (tp == NULL)
return;
const char *sp = (const char *) (*tp);
_item = 0; _line = "";
_item = 0;
_line = "";
int ndx = 0, p = 0;
bool first = TRUE;
_cur_line = n;
@ -128,21 +163,30 @@ void TTextfile::read_line(long n, long pos, bool pg)
while (ch && (ch == '@' || (ch == '$' && *sp == '[')))
{
if (ch == '@') // font style change ?
{
style sss = _trans_style (*sp++);
if (sss == normal) stl = (long)col << 16; else stl |= (long)sss;
if (sss == normal)
stl = (long) col << 16;
else
stl |= (long) sss;
}
else if (ch == '$' && *sp == '[') // color change
{
++sp; // eat '['
col = *sp++;
++sp; // eat ','
col |= ((int) (*sp++) << 8);
++sp; // eat ']'
stl = (stl & 0x0000ffff) | ((long) col << 16);
}
ch = *sp++;
} // while
}
if (ch && p >= pos)
{
@ -157,9 +201,11 @@ void TTextfile::read_line(long n, long pos, bool pg)
_item = 0;
}
const char* TTextfile::line(long j, long pos)
const char *TTextfile ::
line (long j, long pos)
{
if (_cur_line != j) read_line(j);
if (_cur_line != j)
read_line (j);
*mytmpstr = '\0';
_line.restart ();
for (int i = 0; i < _line.items (); i++)
@ -167,7 +213,8 @@ const char* TTextfile::line(long j, long pos)
return strlen (mytmpstr) > (word) pos ? &(mytmpstr[pos]) : "";
}
long TTextfile::get_attribute(int pos)
long TTextfile ::
get_attribute (int pos)
{
long stl = 0;
if (pos == -1)
@ -177,42 +224,51 @@ long TTextfile::get_attribute(int pos)
}
else
{
int x = 0, nd = 0; const char* c;
int x = 0, nd = 0;
const char *c;
_line.restart ();
while (c = _line.get ())
{
x += strlen (c);
stl = _styles[nd++];
if ((x-1) >= pos) break; }
if ((x - 1) >= pos)
break;
}
}
return stl;
}
int TTextfile::get_style(int pos)
int TTextfile ::
get_style (int pos)
{
long x = get_attribute (pos);
return (int) (x & 0x0000ffff);
}
char TTextfile::get_background(int pos)
char TTextfile ::
get_background (int pos)
{
long x = get_attribute (pos);
return (char) (x >> 24);
}
char TTextfile::get_foreground(int pos)
char TTextfile ::
get_foreground (int pos)
{
long x = get_attribute (pos);
return (char) ((x >> 16) & 0x000000ff);
}
const char* TTextfile::piece()
const char *TTextfile ::
piece ()
{
if (_item >= _line.items()) return NULL;
if (_item >= _line.items ())
return NULL;
return strcpy (mytmpstr, (const char *) _line.get (_item++));
}
const char* TTextfile::word_at(long x, long y)
const char *TTextfile ::
word_at (long x, long y)
{
CHECK (_isopen, "Attempt operation on closed file");
TString s (line (y));
@ -223,22 +279,29 @@ const char* TTextfile::word_at(long x, long y)
while (isspace (s[(int) x]))
{
if (x == (s.len () - 1) && y < (_lines - 1l))
{ s = line(++y); x = 0l;}
else if (x < (s.len() - 1)) x++;
else break;
{
s = line (++y);
x = 0l;
}
while (isalnum(s[(int)x])) mytmpstr[x2++] = s[(int)x++];
else if (x < (s.len () - 1))
x++;
else
break;
}
while (isalnum (s[(int) x]))
mytmpstr[x2++] = s[(int) x++];
}
mytmpstr[x2] = '\0';
return mytmpstr;
}
bool TTextfile::append(const char* l)
bool TTextfile ::
append (const char *l)
{
CHECK (_isopen, "Attempt operation on closed file");
if (!_accept) return FALSE;
if (!_accept)
return FALSE;
fseek (_instr, 0l, SEEK_END);
fseek (_index, 0l, SEEK_END);
@ -250,9 +313,11 @@ bool TTextfile::append(const char* l)
error_box ("Errore di scrittura file temporaneo: scrittura interrotta");
freeze ();
}
fflush(_index); fflush(_instr);
fflush (_index);
fflush (_instr);
_lines++; _dirty = TRUE;
_lines++;
_dirty = TRUE;
if ((_lines) < (_page_start + _page_size))
{
@ -260,7 +325,8 @@ bool TTextfile::append(const char* l)
_page.add (ll);
_page_end++;
int len = 0; const char* cp;
int len = 0;
const char *cp;
read_line (_lines - 1);
while (cp = piece ())
{
@ -271,8 +337,12 @@ bool TTextfile::append(const char* l)
{
TToken_string *tts = new TToken_string (50);
tts->add (_lines - 1l); // line number
tts->add(len); tts->add(len + (int)strlen(cp) );
tts->add(cp); tts->add(z);
//
tts->add (len);
tts->add (len + (int) strlen (cp));
tts->add (cp);
tts->add (z);
_spots.add (tts);
break;
}
@ -284,7 +354,8 @@ bool TTextfile::append(const char* l)
return FALSE;
}
void TTextfile::close()
void TTextfile ::
close ()
{
CHECK (_isopen, "Attempt operation on closed file");
fclose (_instr);
@ -293,7 +364,8 @@ void TTextfile::close()
_isopen = FALSE;
}
void TTextfile::print()
void TTextfile ::
print ()
{
CHECK (_isopen, "Attempt operation on closed file");
warning_box ("Funzione non ancora implementata");
@ -302,8 +374,8 @@ void TTextfile::print()
// print
}
bool TTextfile::write(const char* path, TPoint* from, TPoint* to)
bool TTextfile ::
write (const char *path, TPoint * from, TPoint * to)
{
bool ok = FALSE;
FILE *fp;
@ -318,28 +390,35 @@ bool TTextfile::write(const char* path, TPoint* from, TPoint* to)
for (long j = starty; j <= endy; j++)
{
s = line (j);
if (j == endy && endx == -1) endx = s.len();
if (j == endy && endx == -1)
endx = s.len ();
if (j == starty && j == endy) s = s.sub(startx,endx);
else if (j == starty) s = s.mid(startx);
else if (j == endy) s = s.left(endx);
if (j == starty && j == endy)
s = s.sub (startx, endx);
else if (j == starty)
s = s.mid (startx);
else if (j == endy)
s = s.left (endx);
fprintf (fp, "%s\n", (const char *) s);
}
fclose (fp);
}
else warning_box("Impossibile scrivere il file %s; scrittura fallita", path);
else
warning_box ("Impossibile scrivere il file %s; scrittura fallita", path);
return ok;
}
void TTextfile::destroy()
void TTextfile ::
destroy ()
{
CHECK (_istemp, "destroy() chiamata su testo permanente!");
if (_page.items () > 0)
{
if (_index) fclose(_index);
if (_instr) fclose(_instr);
if (_index)
fclose (_index);
if (_instr)
fclose (_instr);
remove ((const char *) _filename);
remove ((const char *) _indname);
_page_start = _lines = 0l;
@ -359,15 +438,19 @@ void TTextfile::destroy()
}
}
TTextfile ::TTextfile (const char *file, int pagesize, direction preferred):
_page_size (pagesize), _page (pagesize), _filename (file), _lines (0l),
_index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred),
_dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
_hotspots(4), _accept(TRUE)
_hotspots (4),
_accept (TRUE)
{
// open file & build index
if (file == NULL) { _filename.temp(); _istemp = TRUE; }
if (file == NULL)
{
_filename.temp ();
_istemp = TRUE;
}
_instr = fopen (_filename, "a+");
_indname.temp ();
@ -394,14 +477,13 @@ TTextfile::TTextfile(const char* file, int pagesize, direction preferred) :
_isopen = TRUE;
}
TTextfile ::~TTextfile ()
{
if (_index) fclose(_index);
if (_instr) fclose(_instr);
if (_istemp) remove((const char*)_filename);
if (_index)
fclose (_index);
if (_instr)
fclose (_instr);
if (_istemp)
remove ((const char *) _filename);
remove ((const char *) _indname);
}

File diff suppressed because it is too large Load Diff