*** 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];
 | 
					static char mytmpstr[257];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class _HotSpot:public TObject
 | 
					class _HotSpot : public TObject
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  public:
 | 
					  public:
 | 
				
			||||||
//      TArray _spots;  // tokenstrings
 | 
					//      TArray _spots;  // tokenstrings
 | 
				
			||||||
@ -20,15 +20,13 @@ class _HotSpot:public TObject
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TTextfile ::
 | 
					void TTextfile::set_hotspots (char fg, char bg)
 | 
				
			||||||
set_hotspots (char fg, char bg)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  _HotSpot *hp = new _HotSpot (fg, bg);
 | 
					  _HotSpot *hp = new _HotSpot (fg, bg);
 | 
				
			||||||
  _hotspots.add (hp);
 | 
					  _hotspots.add (hp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
style TTextfile ::
 | 
					style TTextfile::_trans_style (char ch)
 | 
				
			||||||
_trans_style (char ch)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  switch (ch)
 | 
					  switch (ch)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -56,8 +54,7 @@ _trans_style (char ch)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TTextfile ::
 | 
					void TTextfile::_read_page (long n)
 | 
				
			||||||
_read_page (long n)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  switch (_direction)
 | 
					  switch (_direction)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -91,7 +88,7 @@ _read_page (long n)
 | 
				
			|||||||
  for (long i = _page_start; i <= _page_end; i++)
 | 
					  for (long i = _page_start; i <= _page_end; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      if (feof (_instr))
 | 
					      if (feof (_instr))
 | 
				
			||||||
	break;
 | 
					        break;
 | 
				
			||||||
      fgets (mytmpstr, sizeof (mytmpstr), _instr);
 | 
					      fgets (mytmpstr, sizeof (mytmpstr), _instr);
 | 
				
			||||||
      mytmpstr[strlen (mytmpstr) - 1] = '\0';
 | 
					      mytmpstr[strlen (mytmpstr) - 1] = '\0';
 | 
				
			||||||
      TString & ts = (TString &) _page[(int) (i - _page_start)];
 | 
					      TString & ts = (TString &) _page[(int) (i - _page_start)];
 | 
				
			||||||
@ -103,30 +100,29 @@ _read_page (long n)
 | 
				
			|||||||
      const char *cp;
 | 
					      const char *cp;
 | 
				
			||||||
      read_line (i, 0, FALSE);
 | 
					      read_line (i, 0, FALSE);
 | 
				
			||||||
      while (cp = piece ())
 | 
					      while (cp = piece ())
 | 
				
			||||||
	{
 | 
					        {
 | 
				
			||||||
	  for (int z = 0; z < _hotspots.items (); z++)
 | 
					          for (int z = 0; z < _hotspots.items (); z++)
 | 
				
			||||||
	    {
 | 
					            {
 | 
				
			||||||
	      _HotSpot & hs = (_HotSpot &) _hotspots[z];
 | 
					              _HotSpot & hs = (_HotSpot &) _hotspots[z];
 | 
				
			||||||
	      if (hs._fg == get_foreground () && hs._bg == get_background ())
 | 
					              if (hs._fg == get_foreground () && hs._bg == get_background ())
 | 
				
			||||||
		{
 | 
					                {
 | 
				
			||||||
		  TToken_string *tts = new TToken_string (50);
 | 
					                  TToken_string *tts = new TToken_string (50);
 | 
				
			||||||
		  tts->add (i);	// line number                        
 | 
					                  tts->add (i); // line number                        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		  tts->add (len);
 | 
					                  tts->add (len);
 | 
				
			||||||
		  tts->add (len + (int) strlen (cp));
 | 
					                  tts->add (len + (int) strlen (cp));
 | 
				
			||||||
		  tts->add (cp);
 | 
					                  tts->add (cp);
 | 
				
			||||||
		  tts->add (z);
 | 
					                  tts->add (z);
 | 
				
			||||||
		  _spots.add (tts);
 | 
					                  _spots.add (tts);
 | 
				
			||||||
		  break;
 | 
					                  break;
 | 
				
			||||||
		}
 | 
					                }
 | 
				
			||||||
	    }
 | 
					            }
 | 
				
			||||||
	  len += strlen (cp);
 | 
					          len += strlen (cp);
 | 
				
			||||||
	}
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TTextfile ::
 | 
					void TTextfile::read_line (long n, long pos, bool pg)
 | 
				
			||||||
read_line (long n, long pos, bool pg)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  CHECK (_isopen, "Attempt operation on closed file");
 | 
					  CHECK (_isopen, "Attempt operation on closed file");
 | 
				
			||||||
  CHECKD (n >= 0 && n < _lines, "Line not present", n);
 | 
					  CHECKD (n >= 0 && n < _lines, "Line not present", n);
 | 
				
			||||||
@ -201,8 +197,7 @@ read_line (long n, long pos, bool pg)
 | 
				
			|||||||
  _item = 0;
 | 
					  _item = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *TTextfile ::
 | 
					const char *TTextfile::line (long j, long pos)
 | 
				
			||||||
line (long j, long pos)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (_cur_line != j)
 | 
					  if (_cur_line != j)
 | 
				
			||||||
    read_line (j);
 | 
					    read_line (j);
 | 
				
			||||||
@ -213,8 +208,7 @@ line (long j, long pos)
 | 
				
			|||||||
  return strlen (mytmpstr) > (word) pos ? &(mytmpstr[pos]) : "";
 | 
					  return strlen (mytmpstr) > (word) pos ? &(mytmpstr[pos]) : "";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
long TTextfile ::
 | 
					long TTextfile::get_attribute (int pos)
 | 
				
			||||||
get_attribute (int pos)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  long stl = 0;
 | 
					  long stl = 0;
 | 
				
			||||||
  if (pos == -1)
 | 
					  if (pos == -1)
 | 
				
			||||||
@ -238,37 +232,32 @@ get_attribute (int pos)
 | 
				
			|||||||
  return stl;
 | 
					  return stl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int TTextfile ::
 | 
					int TTextfile::get_style (int pos)
 | 
				
			||||||
get_style (int pos)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  long x = get_attribute (pos);
 | 
					  long x = get_attribute (pos);
 | 
				
			||||||
  return (int) (x & 0x0000ffff);
 | 
					  return (int) (x & 0x0000ffff);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char TTextfile ::
 | 
					char TTextfile::get_background (int pos)
 | 
				
			||||||
get_background (int pos)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  long x = get_attribute (pos);
 | 
					  long x = get_attribute (pos);
 | 
				
			||||||
  return (char) (x >> 24);
 | 
					  return (char) (x >> 24);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char TTextfile ::
 | 
					char TTextfile::get_foreground (int pos)
 | 
				
			||||||
get_foreground (int pos)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  long x = get_attribute (pos);
 | 
					  long x = get_attribute (pos);
 | 
				
			||||||
  return (char) ((x >> 16) & 0x000000ff);
 | 
					  return (char) ((x >> 16) & 0x000000ff);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *TTextfile ::
 | 
					const char *TTextfile::piece ()
 | 
				
			||||||
piece ()
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (_item >= _line.items ())
 | 
					  if (_item >= _line.items ())
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
  return strcpy (mytmpstr, (const char *) _line.get (_item++));
 | 
					  return strcpy (mytmpstr, (const char *) _line.get (_item++));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *TTextfile ::
 | 
					const char *TTextfile::word_at (long x, long y)
 | 
				
			||||||
word_at (long x, long y)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  CHECK (_isopen, "Attempt operation on closed file");
 | 
					  CHECK (_isopen, "Attempt operation on closed file");
 | 
				
			||||||
  TString s (line (y));
 | 
					  TString s (line (y));
 | 
				
			||||||
@ -295,8 +284,7 @@ word_at (long x, long y)
 | 
				
			|||||||
  return mytmpstr;
 | 
					  return mytmpstr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool TTextfile ::
 | 
					bool TTextfile::append (const char *l)
 | 
				
			||||||
append (const char *l)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  CHECK (_isopen, "Attempt operation on closed file");
 | 
					  CHECK (_isopen, "Attempt operation on closed file");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -354,8 +342,7 @@ append (const char *l)
 | 
				
			|||||||
  return FALSE;
 | 
					  return FALSE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TTextfile ::
 | 
					void TTextfile::close ()
 | 
				
			||||||
close ()
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  CHECK (_isopen, "Attempt operation on closed file");
 | 
					  CHECK (_isopen, "Attempt operation on closed file");
 | 
				
			||||||
  fclose (_instr);
 | 
					  fclose (_instr);
 | 
				
			||||||
@ -364,8 +351,7 @@ close ()
 | 
				
			|||||||
  _isopen = FALSE;
 | 
					  _isopen = FALSE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TTextfile ::
 | 
					void TTextfile::print ()
 | 
				
			||||||
print ()
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  CHECK (_isopen, "Attempt operation on closed file");
 | 
					  CHECK (_isopen, "Attempt operation on closed file");
 | 
				
			||||||
  warning_box ("Funzione non ancora implementata");
 | 
					  warning_box ("Funzione non ancora implementata");
 | 
				
			||||||
@ -374,8 +360,7 @@ print ()
 | 
				
			|||||||
  // print
 | 
					  // print
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool TTextfile ::
 | 
					bool TTextfile::write (const char *path, TPoint * from, TPoint * to)
 | 
				
			||||||
write (const char *path, TPoint * from, TPoint * to)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  bool ok = FALSE;
 | 
					  bool ok = FALSE;
 | 
				
			||||||
  FILE *fp;
 | 
					  FILE *fp;
 | 
				
			||||||
@ -409,8 +394,7 @@ write (const char *path, TPoint * from, TPoint * to)
 | 
				
			|||||||
  return ok;
 | 
					  return ok;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TTextfile ::
 | 
					void TTextfile::destroy ()
 | 
				
			||||||
destroy ()
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  CHECK (_istemp, "destroy() chiamata su testo permanente!");
 | 
					  CHECK (_istemp, "destroy() chiamata su testo permanente!");
 | 
				
			||||||
  if (_page.items () > 0)
 | 
					  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),
 | 
					  _page_size (pagesize), _page (pagesize), _filename (file), _lines (0l),
 | 
				
			||||||
  _index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred),
 | 
					  _index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred),
 | 
				
			||||||
  _dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
 | 
					  _dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
 | 
				
			||||||
  _hotspots (4), 
 | 
					  _hotspots (4), _accept (TRUE)
 | 
				
			||||||
_accept (TRUE)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  // open file & build index
 | 
					  // open file & build index
 | 
				
			||||||
  if (file == NULL)
 | 
					  if (file == NULL)
 | 
				
			||||||
@ -477,7 +460,7 @@ _accept (TRUE)
 | 
				
			|||||||
  _isopen = TRUE;
 | 
					  _isopen = TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TTextfile ::~TTextfile ()
 | 
					TTextfile::~TTextfile ()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (_index)
 | 
					  if (_index)
 | 
				
			||||||
    fclose (_index);
 | 
					    fclose (_index);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user