*** empty log message ***
git-svn-id: svn://10.65.10.50/trunk@19 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									3f5ce20380
								
							
						
					
					
						commit
						a0136bf864
					
				@ -4,7 +4,7 @@
 | 
			
		||||
 | 
			
		||||
static char mytmpstr[257];
 | 
			
		||||
 | 
			
		||||
class _HotSpot:public TObject
 | 
			
		||||
class _HotSpot : public TObject
 | 
			
		||||
{
 | 
			
		||||
  public:
 | 
			
		||||
//      TArray _spots;  // tokenstrings
 | 
			
		||||
@ -20,15 +20,13 @@ class _HotSpot:public TObject
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
@ -56,8 +54,7 @@ _trans_style (char ch)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TTextfile ::
 | 
			
		||||
_read_page (long n)
 | 
			
		||||
void TTextfile::_read_page (long n)
 | 
			
		||||
{
 | 
			
		||||
  switch (_direction)
 | 
			
		||||
    {
 | 
			
		||||
@ -91,7 +88,7 @@ _read_page (long n)
 | 
			
		||||
  for (long i = _page_start; i <= _page_end; i++)
 | 
			
		||||
    {
 | 
			
		||||
      if (feof (_instr))
 | 
			
		||||
	break;
 | 
			
		||||
        break;
 | 
			
		||||
      fgets (mytmpstr, sizeof (mytmpstr), _instr);
 | 
			
		||||
      mytmpstr[strlen (mytmpstr) - 1] = '\0';
 | 
			
		||||
      TString & ts = (TString &) _page[(int) (i - _page_start)];
 | 
			
		||||
@ -103,30 +100,29 @@ _read_page (long n)
 | 
			
		||||
      const char *cp;
 | 
			
		||||
      read_line (i, 0, FALSE);
 | 
			
		||||
      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 (i);	// line number                        
 | 
			
		||||
        {
 | 
			
		||||
          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 (i); // line number                        
 | 
			
		||||
 | 
			
		||||
		  tts->add (len);
 | 
			
		||||
		  tts->add (len + (int) strlen (cp));
 | 
			
		||||
		  tts->add (cp);
 | 
			
		||||
		  tts->add (z);
 | 
			
		||||
		  _spots.add (tts);
 | 
			
		||||
		  break;
 | 
			
		||||
		}
 | 
			
		||||
	    }
 | 
			
		||||
	  len += strlen (cp);
 | 
			
		||||
	}
 | 
			
		||||
                  tts->add (len);
 | 
			
		||||
                  tts->add (len + (int) strlen (cp));
 | 
			
		||||
                  tts->add (cp);
 | 
			
		||||
                  tts->add (z);
 | 
			
		||||
                  _spots.add (tts);
 | 
			
		||||
                  break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
          len += strlen (cp);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
@ -201,8 +197,7 @@ 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);
 | 
			
		||||
@ -213,8 +208,7 @@ 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)
 | 
			
		||||
@ -238,37 +232,32 @@ get_attribute (int pos)
 | 
			
		||||
  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;
 | 
			
		||||
  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));
 | 
			
		||||
@ -295,8 +284,7 @@ word_at (long x, long y)
 | 
			
		||||
  return mytmpstr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TTextfile ::
 | 
			
		||||
append (const char *l)
 | 
			
		||||
bool TTextfile::append (const char *l)
 | 
			
		||||
{
 | 
			
		||||
  CHECK (_isopen, "Attempt operation on closed file");
 | 
			
		||||
 | 
			
		||||
@ -354,8 +342,7 @@ append (const char *l)
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TTextfile ::
 | 
			
		||||
close ()
 | 
			
		||||
void TTextfile::close ()
 | 
			
		||||
{
 | 
			
		||||
  CHECK (_isopen, "Attempt operation on closed file");
 | 
			
		||||
  fclose (_instr);
 | 
			
		||||
@ -364,8 +351,7 @@ close ()
 | 
			
		||||
  _isopen = FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TTextfile ::
 | 
			
		||||
print ()
 | 
			
		||||
void TTextfile::print ()
 | 
			
		||||
{
 | 
			
		||||
  CHECK (_isopen, "Attempt operation on closed file");
 | 
			
		||||
  warning_box ("Funzione non ancora implementata");
 | 
			
		||||
@ -374,8 +360,7 @@ 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;
 | 
			
		||||
@ -409,8 +394,7 @@ write (const char *path, TPoint * from, TPoint * to)
 | 
			
		||||
  return ok;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TTextfile ::
 | 
			
		||||
destroy ()
 | 
			
		||||
void TTextfile::destroy ()
 | 
			
		||||
{
 | 
			
		||||
  CHECK (_istemp, "destroy() chiamata su testo permanente!");
 | 
			
		||||
  if (_page.items () > 0)
 | 
			
		||||
@ -442,8 +426,7 @@ 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)
 | 
			
		||||
@ -477,7 +460,7 @@ _accept (TRUE)
 | 
			
		||||
  _isopen = TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TTextfile ::~TTextfile ()
 | 
			
		||||
TTextfile::~TTextfile ()
 | 
			
		||||
{
 | 
			
		||||
  if (_index)
 | 
			
		||||
    fclose (_index);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user