Correzioni a stampe e tabelle
git-svn-id: svn://10.65.10.50/trunk@1366 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
e1b4b71491
commit
b62750d4a9
@ -177,7 +177,7 @@ int TArray::add(
|
||||
// @xref <mf TArray::insert>
|
||||
{
|
||||
if (index < 0) for (index = 0; index < size() && _data[index]; index++);
|
||||
if (index >= size()) resize(3*index/2 + 1);
|
||||
if (index >= size()) resize(int(3L*index/2) + 1);
|
||||
|
||||
if (_data[index] != NULL)
|
||||
{
|
||||
|
@ -1372,6 +1372,7 @@ bool TPrinter::open()
|
||||
{
|
||||
// prepare text object for new text
|
||||
_txt.destroy();
|
||||
_txt.interactive(FALSE);
|
||||
}
|
||||
#if XVT_OS==XVT_OS_SCOUNIX
|
||||
else
|
||||
|
@ -38,12 +38,13 @@ int TTable::first(word lockop)
|
||||
|
||||
int TTable::last(word lockop)
|
||||
|
||||
{
|
||||
{
|
||||
zero();
|
||||
put("CODTAB", "\0xFF");
|
||||
put("CODTAB", "\377");
|
||||
TBaseisamfile::read(_isgteq);
|
||||
if (!eof()) TBaseisamfile::prev(lockop);
|
||||
else setstatus(NOERR);
|
||||
if (bof()) setstatus(NOERR);
|
||||
if (good())
|
||||
if (_tabname != (const char *)_cod) setstatus(_isemptyfile);
|
||||
if (bad()) zero();
|
||||
|
135
include/text.cpp
135
include/text.cpp
@ -145,7 +145,7 @@ void TTextfile::_read_page (long n)
|
||||
if (_page_start != 0l)
|
||||
fread (&l, sizeof (long), 1, _index);
|
||||
fseek (_instr, l, SEEK_SET);
|
||||
|
||||
|
||||
for (long i = _page_start; i <= _page_end; i++)
|
||||
{
|
||||
if (feof (_instr))
|
||||
@ -154,31 +154,34 @@ void TTextfile::_read_page (long n)
|
||||
TEXT_TMP[strlen (TEXT_TMP) - 1] = '\0';
|
||||
TString & ts = (TString &) _page[(int) (i - _page_start)];
|
||||
ts = TEXT_TMP;
|
||||
TString hcol (6);
|
||||
// find hotspots and compile list
|
||||
if (_interactive)
|
||||
{
|
||||
TString hcol (6);
|
||||
// find hotspots and compile list
|
||||
|
||||
int len = 0;
|
||||
const char *cp;
|
||||
read_line (i, 0, FALSE);
|
||||
while (cp = piece ())
|
||||
{
|
||||
for (int z = 0; z < _hotspots.items (); z++)
|
||||
int len = 0;
|
||||
const char *cp;
|
||||
read_line (i, 0, FALSE);
|
||||
while (cp = piece ())
|
||||
{
|
||||
_HotSpot & hs = (_HotSpot &) _hotspots[z];
|
||||
if (hs._fg == get_foreground () && hs._bg == get_background ())
|
||||
for (int z = 0; z < _hotspots.items (); z++)
|
||||
{
|
||||
TToken_string *tts = new TToken_string (50);
|
||||
tts->add (i); // line number
|
||||
_HotSpot & hs = (_HotSpot &) _hotspots[z];
|
||||
if (hs._fg == get_foreground () && hs._bg == get_background ())
|
||||
{
|
||||
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);
|
||||
_spots.add (tts);
|
||||
break;
|
||||
tts->add (len);
|
||||
tts->add (len + (int) strlen (cp));
|
||||
tts->add (cp);
|
||||
tts->add (z);
|
||||
_spots.add (tts);
|
||||
break;
|
||||
}
|
||||
}
|
||||
len += strlen (cp);
|
||||
}
|
||||
len += strlen (cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -446,37 +449,40 @@ bool TTextfile::append (const char *l)
|
||||
fflush (_instr);
|
||||
|
||||
_lines++;
|
||||
_dirty = TRUE;
|
||||
|
||||
_dirty = TRUE;
|
||||
|
||||
if ((_lines) < (_page_start + _page_size))
|
||||
{
|
||||
TString *ll = new TString (l);
|
||||
_page.add (ll);
|
||||
_page_end++;
|
||||
|
||||
int len = 0;
|
||||
const char *cp;
|
||||
read_line (_lines - 1);
|
||||
while (cp = piece ())
|
||||
{
|
||||
if (_interactive)
|
||||
{
|
||||
for (int z = 0; z < _hotspots.items (); z++)
|
||||
{
|
||||
_HotSpot & hs = (_HotSpot &) _hotspots[z];
|
||||
if (hs._fg == get_foreground () && hs._bg == get_background ())
|
||||
{
|
||||
TToken_string *tts = new TToken_string (50);
|
||||
tts->add (_lines - 1l); // line number
|
||||
//
|
||||
TString *ll = new TString (l);
|
||||
_page.add (ll, _lines - _page_start - 1);
|
||||
_page_end++;
|
||||
|
||||
tts->add (len);
|
||||
tts->add (len + (int) strlen (cp));
|
||||
tts->add (cp);
|
||||
tts->add (z);
|
||||
_spots.add (tts);
|
||||
break;
|
||||
int len = 0;
|
||||
const char *cp;
|
||||
read_line (_lines - 1);
|
||||
while (cp = piece ())
|
||||
{
|
||||
for (int z = 0; z < _hotspots.items (); z++)
|
||||
{
|
||||
_HotSpot & hs = (_HotSpot &) _hotspots[z];
|
||||
if (hs._fg == get_foreground () && hs._bg == get_background ())
|
||||
{
|
||||
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);
|
||||
_spots.add (tts);
|
||||
break;
|
||||
}
|
||||
}
|
||||
len += strlen (cp);
|
||||
}
|
||||
len += strlen (cp);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -558,23 +564,26 @@ void TTextfile::destroy ()
|
||||
freeze ();
|
||||
}
|
||||
_isopen = TRUE;
|
||||
_page.destroy ();
|
||||
// _page.destroy ();
|
||||
_spots.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), _dirty_lines(pagesize)
|
||||
TTextfile ::TTextfile (const char *file, int pagesize, direction preferred,
|
||||
bool interactive):
|
||||
_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), _dirty_lines(pagesize), _interactive(interactive)
|
||||
{
|
||||
// open file & build index
|
||||
if (file == NULL || *file <= ' ')
|
||||
{
|
||||
_filename.temp("txtf");
|
||||
_istemp = TRUE;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < pagesize; i++)
|
||||
_page.add(new TString(132));
|
||||
_isopen = TRUE;
|
||||
|
||||
_instr = fopen (_filename, "a+");
|
||||
@ -598,16 +607,16 @@ _hotspots (4), _accept (TRUE), _dirty_lines(pagesize)
|
||||
}
|
||||
if (fgets (TEXT_TMP, sizeof (TEXT_TMP), _instr) == NULL)
|
||||
break;
|
||||
if (TEXT_TMP[strlen(TEXT_TMP)-1] == '\n')
|
||||
TEXT_TMP[strlen(TEXT_TMP)-1] = '\0';
|
||||
if ((_lines) < (_page_start + _page_size))
|
||||
{
|
||||
TString *ll = new TString (TEXT_TMP);
|
||||
_page.add(ll);
|
||||
_page_end++;
|
||||
|
||||
// TBI process links
|
||||
}
|
||||
// if (TEXT_TMP[strlen(TEXT_TMP)-1] == '\n')
|
||||
// TEXT_TMP[strlen(TEXT_TMP)-1] = '\0';
|
||||
// if ((_lines) < (_page_start + _page_size))
|
||||
// {
|
||||
// TString *ll = new TString (TEXT_TMP);
|
||||
// _page.add(ll);
|
||||
// _page_end++;
|
||||
|
||||
// TBI process links
|
||||
// }
|
||||
_lines++;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ class TTextfile: public TObject
|
||||
bool _dirty;
|
||||
bool _isopen;
|
||||
bool _istemp;
|
||||
bool _accept;
|
||||
bool _accept;
|
||||
bool _interactive;
|
||||
|
||||
void _read_page(long line);
|
||||
bool _in_page(long l)
|
||||
@ -100,6 +101,7 @@ public:
|
||||
// allochera' un altro TText che deve essere disfatto dall'utente
|
||||
TTextfile* section(TPoint& from, TPoint& to) { return this; }
|
||||
const char* name() { return (const char*)_filename; }
|
||||
void interactive(bool on = TRUE) { _interactive = on; }
|
||||
|
||||
// scrive il testo (non formattato) su file, da punto a punto
|
||||
// (tutto per default)
|
||||
@ -123,7 +125,7 @@ public:
|
||||
TArray& hotspots() { return _spots; }
|
||||
|
||||
TTextfile(const char* file = NULL, int pagesize = DEFAULT_PAGESIZE,
|
||||
direction preferred = updown);
|
||||
direction preferred = updown, bool interactive = TRUE);
|
||||
virtual ~TTextfile();
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user