Tolto l'infame formfeed su stampe per export
Aggiunte figatelle a browsefield e viswin git-svn-id: svn://10.65.10.50/trunk@788 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
fbebe9c72c
commit
240fe63fc1
@ -35,8 +35,11 @@ public:
|
||||
TViswin* vis_win() const { return _viswin; }
|
||||
|
||||
void add_line(const char* l);
|
||||
long set_text(const char* file, const char* line = NULL);
|
||||
// TBI posiziona su riga e colonna passate
|
||||
long set_text(const char* file, const char* line = NULL);
|
||||
|
||||
const char* get_text(long line, int column = 0, int len = -1);
|
||||
|
||||
// posiziona su riga e colonna passate
|
||||
void goto_pos(long r, long c);
|
||||
void goto_top();
|
||||
void goto_end();
|
||||
@ -53,6 +56,7 @@ public:
|
||||
int enable_link (const char* descr, char fg, char bg = 'w');
|
||||
void disable_link(char fg, char bg = 'w');
|
||||
void disable_links() { _links.destroy(); }
|
||||
long lines();
|
||||
|
||||
// print background
|
||||
void set_background(const char* bg);
|
||||
|
@ -1391,8 +1391,10 @@ void TPrinter::close ()
|
||||
{
|
||||
const bool isfirstpage = (_currentpage == 1 && _frompage == 0) ||
|
||||
(_currentpage <= _frompage);
|
||||
if (isopen () && (!isfirstpage || _currentrow > _headersize) &&
|
||||
(_printertype != screenvis && _printertype != winprinter))
|
||||
|
||||
if (isopen() && (!isfirstpage || _currentrow > _headersize) &&
|
||||
(_printertype != screenvis && _printertype != winprinter
|
||||
&& _printertype != export))
|
||||
formfeed();
|
||||
|
||||
if (_fp)
|
||||
@ -1499,13 +1501,11 @@ void TFile_printer::open()
|
||||
{
|
||||
}
|
||||
|
||||
void TFile_printer ::
|
||||
close ()
|
||||
void TFile_printer::close ()
|
||||
{
|
||||
}
|
||||
|
||||
bool TFile_printer ::
|
||||
genera_dischetti ()
|
||||
bool TFile_printer::genera_dischetti ()
|
||||
{
|
||||
int r;
|
||||
|
||||
@ -1569,11 +1569,11 @@ void TFile_printer::set ()
|
||||
|
||||
if (tasto == K_ENTER)
|
||||
{
|
||||
f = atoi (m.get (F_FORMATO_DISCO));
|
||||
_drive = m.get (F_DRIVE);
|
||||
_file = m.get (F_FILE_DESTINAZIONE);
|
||||
_label = m.get (F_LABEL);
|
||||
_formatta = (bool) (m.get (F_FORMATTA) == "X");
|
||||
f = atoi(m.get(F_FORMATO_DISCO));
|
||||
_drive = m.get(F_DRIVE);
|
||||
_file = m.get(F_FILE_DESTINAZIONE);
|
||||
_label = m.get(F_LABEL);
|
||||
_formatta = (bool)(m.get(F_FORMATTA) == "X");
|
||||
_size = disk_sizes[f];
|
||||
_num_rec_volume = int ((_size / _len_rec) - _num_rec_testa_coda);
|
||||
}
|
||||
|
@ -197,17 +197,79 @@ 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, int howmuch)
|
||||
{
|
||||
if (_cur_line != j)
|
||||
read_line (j);
|
||||
*mytmpstr = '\0';
|
||||
_line.restart ();
|
||||
for (int i = 0; i < _line.items (); i++)
|
||||
strcat (mytmpstr, (const char *) _line.get ());
|
||||
return strlen (mytmpstr) > (word) pos ? &(mytmpstr[pos]) : "";
|
||||
strcat (mytmpstr, (const char *) _line.get ());
|
||||
if (howmuch != -1)
|
||||
{
|
||||
if (((unsigned int)pos+howmuch) < strlen(mytmpstr))
|
||||
mytmpstr[pos+howmuch] = '\0';
|
||||
}
|
||||
return strlen(mytmpstr) > (word)pos ? &(mytmpstr[pos]) : "";
|
||||
}
|
||||
|
||||
|
||||
long TTextfile::search(const char* txt, int& ret, long from, bool down)
|
||||
{
|
||||
TString256 lin;
|
||||
for (long i = from; down ? (i < lines()) : (i >= 0); down ? i++ : i--)
|
||||
{
|
||||
lin = line(i);
|
||||
if ((ret = lin.find(txt)) != -1)
|
||||
return i;
|
||||
}
|
||||
return -1l;
|
||||
}
|
||||
|
||||
int TTextfile::replace(long l, const char* txt, int pos, int len)
|
||||
{
|
||||
if (_cur_line != l)
|
||||
read_line(l);
|
||||
|
||||
TString& line = (TString&)_page[int(l-_page_start)];
|
||||
|
||||
char ch; int i = 0, cnt = 0, skip = 0;
|
||||
bool sforating = FALSE;
|
||||
|
||||
// here's a nice casin
|
||||
while(i < 256)
|
||||
{
|
||||
if (!sforating)
|
||||
{
|
||||
ch = line[i++];
|
||||
if (ch == '\0')
|
||||
sforating = TRUE;
|
||||
else if (ch == '@' && strchr("ribuok",line[i]) != NULL)
|
||||
{
|
||||
skip +=2; i++;
|
||||
}
|
||||
else if (ch == '$' && line[i] == '[')
|
||||
{
|
||||
skip +=3; i++;
|
||||
while(line[i++] != ']')
|
||||
if (line[i] == '\0')
|
||||
return -1;
|
||||
else skip++;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt == pos)
|
||||
{
|
||||
line.overwrite(txt, cnt+skip);
|
||||
return cnt;
|
||||
}
|
||||
else cnt++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
const char *TTextfile::line_formatted(long j)
|
||||
{
|
||||
if (_cur_line != j)
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
bool changed() { return _dirty; }
|
||||
|
||||
// line() ritorna la stringa di caratteri senza formattazione
|
||||
const char* line(long row, long column = 0);
|
||||
const char* line(long row, long column = 0, int howmuch = -1);
|
||||
// line_formatted() la ritorna, come e' logico attendersi, con
|
||||
// la formattazione
|
||||
const char* line_formatted(long row);
|
||||
@ -106,6 +106,14 @@ public:
|
||||
// disfa tutto e svuota il file
|
||||
void destroy();
|
||||
|
||||
// search and replace (una riga per volta, rispetta i formati)
|
||||
// txt = text to search; pos = int to put the char position in;
|
||||
// from = where to start; down = FALSE == up
|
||||
long search (const char* txt, int& pos, long from = 0, bool down = TRUE);
|
||||
// replace txt=txt in line=line at pos=pos for len=len
|
||||
int replace(long line, const char* txt, int pos = 0, int len = -1);
|
||||
|
||||
|
||||
// hypertext cazzuls
|
||||
// le si dice il colore che devono avere i punti selezionabili;
|
||||
// ritorna l'array in cui vengono messi gli hotspots relativi alla
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
#include <viswin.h>
|
||||
#include <bagn005.h>
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
typedef void (*LINKHANDLER) (int, const char *);
|
||||
@ -51,7 +52,6 @@ extern "C"
|
||||
#define CTRL_E (K_CTRL + 'E')
|
||||
#define CTRL_S (K_CTRL + 'S')
|
||||
#define CTRL_R (K_CTRL + 'R')
|
||||
#define K_CTRLTAB (K_CTRL + K_TAB)
|
||||
|
||||
// vista la mania degli 883, eccoti un po' di concerti di Mozart
|
||||
const long E_ADDLINE = 488L;
|
||||
@ -857,7 +857,8 @@ void TViswin::update ()
|
||||
bar ((X_OFFSET-1), rows()-BUTTONROW_SIZE, columns()+1, rows() + 1);
|
||||
}
|
||||
if (_need_update)
|
||||
{
|
||||
{
|
||||
check_link();
|
||||
if (_isselection)
|
||||
erase_selection ();
|
||||
clear (COLOR_WHITE);
|
||||
@ -890,7 +891,8 @@ else if (_toplevel)
|
||||
if (_isselection)
|
||||
display_selection ();
|
||||
}
|
||||
display_point ();
|
||||
display_point ();
|
||||
check_link(&_point);
|
||||
autoscroll (TRUE);
|
||||
_need_update = TRUE;
|
||||
_need_scroll = none;
|
||||
@ -1365,7 +1367,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
if (ep->type == E_VSCROLL)
|
||||
{
|
||||
_need_update = FALSE;
|
||||
if ((origin ().y + _textrows) < _txt.lines ())
|
||||
if ((origin().y + _textrows) < _txt.lines ())
|
||||
{
|
||||
if (need_paint_sel ())
|
||||
erase_selection ();
|
||||
@ -1524,10 +1526,6 @@ bool TViswin::on_key (KEY key)
|
||||
if (_toplevel)
|
||||
exec_link();
|
||||
break;
|
||||
case K_CTRLTAB:
|
||||
if (!_toplevel)
|
||||
_brwfld->mask().send_key(K_TAB,0);
|
||||
break;
|
||||
case K_TAB:
|
||||
if (!is_running())
|
||||
{
|
||||
@ -1906,17 +1904,69 @@ void TViswin::refresh()
|
||||
force_update();
|
||||
}
|
||||
|
||||
int TViswin::search(const char* txt, long from, bool down)
|
||||
long TViswin::search(const char* txt, int& pos, long from, bool down)
|
||||
{
|
||||
return -1l;
|
||||
return _txt.search(txt,pos,from,down);
|
||||
}
|
||||
|
||||
int TViswin::replace(long line, const char* txt, int pos, int len)
|
||||
{
|
||||
return 0;
|
||||
int TViswin::replace(long l, const char* txt, int pos, int len)
|
||||
{
|
||||
int ret = _txt.replace(l,txt,pos,len);
|
||||
if (ret != -1)
|
||||
{
|
||||
TPoint p; p.x = pos; p.y = l;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void TViswin::find()
|
||||
{
|
||||
TMask m("bagn005");
|
||||
|
||||
m.set(F_STRING, _txt_to_find);
|
||||
m.set(F_DIRECT, _down_dir ? "U" : "D");
|
||||
m.set(F_CASE, _case_sensitive ? "X" : "");
|
||||
|
||||
if (m.run() == K_ENTER)
|
||||
{
|
||||
_txt_to_find = m.get(F_STRING);
|
||||
_down_dir = m.get_bool(F_DIRECT);
|
||||
_case_sensitive = m.get_bool(F_CASE);
|
||||
int x;
|
||||
|
||||
long l = search(_txt_to_find, x, _point.y, _down_dir);
|
||||
if (l == -1l)
|
||||
{
|
||||
_last_found.y = -1l;
|
||||
beep();
|
||||
}
|
||||
else
|
||||
{
|
||||
goto_pos(l,(long)x);
|
||||
_last_found.x = (long)x;
|
||||
_last_found.y = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TViswin::find_next()
|
||||
{
|
||||
int x;
|
||||
|
||||
if (_txt_to_find.empty() || _last_found.y == -1l)
|
||||
beep;
|
||||
else
|
||||
{
|
||||
long l = search(_txt_to_find, x, _point.y, _down_dir);
|
||||
if (l == -1)
|
||||
beep();
|
||||
else
|
||||
goto_pos(l,x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TViswin ::TViswin (const char *fname,
|
||||
const char *title,
|
||||
bool editbutton,
|
||||
@ -1932,12 +1982,14 @@ TViswin ::TViswin (const char *fname,
|
||||
_isselection (FALSE), _sel_displayed (FALSE), _cross_displayed (FALSE),
|
||||
_link_displayed (FALSE), _point_displayed (FALSE), _selecting (FALSE),
|
||||
_scrolling (FALSE), _selflag (FALSE), _need_update (TRUE), _need_scroll (none),
|
||||
_multiple (FALSE), _rulers(rulers),
|
||||
_frozen (FALSE), _brwfld(brwfld), _link_button(-1)
|
||||
_multiple (FALSE), _rulers(rulers), _txt_to_find(64),
|
||||
_frozen (FALSE), _brwfld(brwfld), _link_button(-1), _down_dir(TRUE)
|
||||
{
|
||||
if (title == NULL)
|
||||
title = (fname ? fname : "Anteprima di stampa");
|
||||
|
||||
_last_found.y = -1;
|
||||
|
||||
_isopen = fname == NULL || *fname <= ' ';
|
||||
if (_isopen)
|
||||
_filename = _txt.name ();
|
||||
@ -2208,3 +2260,13 @@ void TBrowsefile_field::refresh()
|
||||
{
|
||||
_viswin->refresh();
|
||||
}
|
||||
|
||||
const char* TBrowsefile_field::get_text(long line, int column, int len)
|
||||
{
|
||||
return _viswin->_txt.line(line,(long)column, len);
|
||||
}
|
||||
|
||||
long TBrowsefile_field::lines()
|
||||
{
|
||||
return _viswin->_txt.lines();
|
||||
}
|
||||
|
@ -56,10 +56,15 @@ class TViswin : public TScroll_window
|
||||
long _textrows; // righe di testo
|
||||
long _textcolumns; // indovina indovinello
|
||||
|
||||
TTextfile _txt; // text being displayed
|
||||
TTextfile _txt; // text being displayed
|
||||
long _firstline; // 1rst text line being displayed
|
||||
long _lastline; // last text line being displayed
|
||||
|
||||
TString _txt_to_find; // text to find
|
||||
TPoint _last_found; // position of last find
|
||||
bool _down_dir; // search direction
|
||||
bool _case_sensitive;
|
||||
|
||||
int _formlen; // length of a page
|
||||
|
||||
TPoint _point; // current point position
|
||||
@ -147,8 +152,13 @@ public:
|
||||
|
||||
void add_line(const char* l);
|
||||
|
||||
int search (const char* txt, long from = 0, bool down = FALSE);
|
||||
// non_interactive search and replace
|
||||
long search (const char* txt, int& pos, long from = 0, bool down = TRUE);
|
||||
int replace(long line, const char* txt, int pos = 0, int len = -1);
|
||||
|
||||
// interactive search
|
||||
void find();
|
||||
void find_next();
|
||||
|
||||
TViswin (const char* fname = NULL,
|
||||
const char* title = NULL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user