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
@ -36,7 +36,10 @@ public:
|
|||||||
|
|
||||||
void add_line(const char* l);
|
void add_line(const char* l);
|
||||||
long set_text(const char* file, const char* line = NULL);
|
long set_text(const char* file, const char* line = NULL);
|
||||||
// TBI posiziona su riga e colonna passate
|
|
||||||
|
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_pos(long r, long c);
|
||||||
void goto_top();
|
void goto_top();
|
||||||
void goto_end();
|
void goto_end();
|
||||||
@ -53,6 +56,7 @@ public:
|
|||||||
int enable_link (const char* descr, char fg, char bg = 'w');
|
int enable_link (const char* descr, char fg, char bg = 'w');
|
||||||
void disable_link(char fg, char bg = 'w');
|
void disable_link(char fg, char bg = 'w');
|
||||||
void disable_links() { _links.destroy(); }
|
void disable_links() { _links.destroy(); }
|
||||||
|
long lines();
|
||||||
|
|
||||||
// print background
|
// print background
|
||||||
void set_background(const char* bg);
|
void set_background(const char* bg);
|
||||||
|
@ -1391,8 +1391,10 @@ void TPrinter::close ()
|
|||||||
{
|
{
|
||||||
const bool isfirstpage = (_currentpage == 1 && _frompage == 0) ||
|
const bool isfirstpage = (_currentpage == 1 && _frompage == 0) ||
|
||||||
(_currentpage <= _frompage);
|
(_currentpage <= _frompage);
|
||||||
|
|
||||||
if (isopen() && (!isfirstpage || _currentrow > _headersize) &&
|
if (isopen() && (!isfirstpage || _currentrow > _headersize) &&
|
||||||
(_printertype != screenvis && _printertype != winprinter))
|
(_printertype != screenvis && _printertype != winprinter
|
||||||
|
&& _printertype != export))
|
||||||
formfeed();
|
formfeed();
|
||||||
|
|
||||||
if (_fp)
|
if (_fp)
|
||||||
@ -1499,13 +1501,11 @@ void TFile_printer::open()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFile_printer ::
|
void TFile_printer::close ()
|
||||||
close ()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TFile_printer ::
|
bool TFile_printer::genera_dischetti ()
|
||||||
genera_dischetti ()
|
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ void TTextfile::read_line (long n, long pos, bool pg)
|
|||||||
_item = 0;
|
_item = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *TTextfile::line(long j, long pos)
|
const char *TTextfile::line(long j, long pos, int howmuch)
|
||||||
{
|
{
|
||||||
if (_cur_line != j)
|
if (_cur_line != j)
|
||||||
read_line (j);
|
read_line (j);
|
||||||
@ -205,9 +205,71 @@ const char *TTextfile::line(long j, long pos)
|
|||||||
_line.restart ();
|
_line.restart ();
|
||||||
for (int i = 0; i < _line.items (); i++)
|
for (int i = 0; i < _line.items (); i++)
|
||||||
strcat (mytmpstr, (const char *) _line.get ());
|
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]) : "";
|
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)
|
const char *TTextfile::line_formatted(long j)
|
||||||
{
|
{
|
||||||
if (_cur_line != j)
|
if (_cur_line != j)
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
bool changed() { return _dirty; }
|
bool changed() { return _dirty; }
|
||||||
|
|
||||||
// line() ritorna la stringa di caratteri senza formattazione
|
// 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
|
// line_formatted() la ritorna, come e' logico attendersi, con
|
||||||
// la formattazione
|
// la formattazione
|
||||||
const char* line_formatted(long row);
|
const char* line_formatted(long row);
|
||||||
@ -106,6 +106,14 @@ public:
|
|||||||
// disfa tutto e svuota il file
|
// disfa tutto e svuota il file
|
||||||
void destroy();
|
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
|
// hypertext cazzuls
|
||||||
// le si dice il colore che devono avere i punti selezionabili;
|
// le si dice il colore che devono avere i punti selezionabili;
|
||||||
// ritorna l'array in cui vengono messi gli hotspots relativi alla
|
// ritorna l'array in cui vengono messi gli hotspots relativi alla
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
#include <viswin.h>
|
#include <viswin.h>
|
||||||
|
#include <bagn005.h>
|
||||||
|
|
||||||
#ifndef __PRINTER_H
|
#ifndef __PRINTER_H
|
||||||
typedef void (*LINKHANDLER) (int, const char *);
|
typedef void (*LINKHANDLER) (int, const char *);
|
||||||
@ -51,7 +52,6 @@ extern "C"
|
|||||||
#define CTRL_E (K_CTRL + 'E')
|
#define CTRL_E (K_CTRL + 'E')
|
||||||
#define CTRL_S (K_CTRL + 'S')
|
#define CTRL_S (K_CTRL + 'S')
|
||||||
#define CTRL_R (K_CTRL + 'R')
|
#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
|
// vista la mania degli 883, eccoti un po' di concerti di Mozart
|
||||||
const long E_ADDLINE = 488L;
|
const long E_ADDLINE = 488L;
|
||||||
@ -858,6 +858,7 @@ void TViswin::update ()
|
|||||||
}
|
}
|
||||||
if (_need_update)
|
if (_need_update)
|
||||||
{
|
{
|
||||||
|
check_link();
|
||||||
if (_isselection)
|
if (_isselection)
|
||||||
erase_selection ();
|
erase_selection ();
|
||||||
clear (COLOR_WHITE);
|
clear (COLOR_WHITE);
|
||||||
@ -891,6 +892,7 @@ else if (_toplevel)
|
|||||||
display_selection ();
|
display_selection ();
|
||||||
}
|
}
|
||||||
display_point ();
|
display_point ();
|
||||||
|
check_link(&_point);
|
||||||
autoscroll (TRUE);
|
autoscroll (TRUE);
|
||||||
_need_update = TRUE;
|
_need_update = TRUE;
|
||||||
_need_scroll = none;
|
_need_scroll = none;
|
||||||
@ -1524,10 +1526,6 @@ bool TViswin::on_key (KEY key)
|
|||||||
if (_toplevel)
|
if (_toplevel)
|
||||||
exec_link();
|
exec_link();
|
||||||
break;
|
break;
|
||||||
case K_CTRLTAB:
|
|
||||||
if (!_toplevel)
|
|
||||||
_brwfld->mask().send_key(K_TAB,0);
|
|
||||||
break;
|
|
||||||
case K_TAB:
|
case K_TAB:
|
||||||
if (!is_running())
|
if (!is_running())
|
||||||
{
|
{
|
||||||
@ -1906,14 +1904,66 @@ void TViswin::refresh()
|
|||||||
force_update();
|
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)
|
int TViswin::replace(long l, const char* txt, int pos, int len)
|
||||||
{
|
{
|
||||||
return 0;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1932,12 +1982,14 @@ TViswin ::TViswin (const char *fname,
|
|||||||
_isselection (FALSE), _sel_displayed (FALSE), _cross_displayed (FALSE),
|
_isselection (FALSE), _sel_displayed (FALSE), _cross_displayed (FALSE),
|
||||||
_link_displayed (FALSE), _point_displayed (FALSE), _selecting (FALSE),
|
_link_displayed (FALSE), _point_displayed (FALSE), _selecting (FALSE),
|
||||||
_scrolling (FALSE), _selflag (FALSE), _need_update (TRUE), _need_scroll (none),
|
_scrolling (FALSE), _selflag (FALSE), _need_update (TRUE), _need_scroll (none),
|
||||||
_multiple (FALSE), _rulers(rulers),
|
_multiple (FALSE), _rulers(rulers), _txt_to_find(64),
|
||||||
_frozen (FALSE), _brwfld(brwfld), _link_button(-1)
|
_frozen (FALSE), _brwfld(brwfld), _link_button(-1), _down_dir(TRUE)
|
||||||
{
|
{
|
||||||
if (title == NULL)
|
if (title == NULL)
|
||||||
title = (fname ? fname : "Anteprima di stampa");
|
title = (fname ? fname : "Anteprima di stampa");
|
||||||
|
|
||||||
|
_last_found.y = -1;
|
||||||
|
|
||||||
_isopen = fname == NULL || *fname <= ' ';
|
_isopen = fname == NULL || *fname <= ' ';
|
||||||
if (_isopen)
|
if (_isopen)
|
||||||
_filename = _txt.name ();
|
_filename = _txt.name ();
|
||||||
@ -2208,3 +2260,13 @@ void TBrowsefile_field::refresh()
|
|||||||
{
|
{
|
||||||
_viswin->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();
|
||||||
|
}
|
||||||
|
@ -60,6 +60,11 @@ class TViswin : public TScroll_window
|
|||||||
long _firstline; // 1rst text line being displayed
|
long _firstline; // 1rst text line being displayed
|
||||||
long _lastline; // last 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
|
int _formlen; // length of a page
|
||||||
|
|
||||||
TPoint _point; // current point position
|
TPoint _point; // current point position
|
||||||
@ -147,9 +152,14 @@ public:
|
|||||||
|
|
||||||
void add_line(const char* l);
|
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);
|
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,
|
TViswin (const char* fname = NULL,
|
||||||
const char* title = NULL,
|
const char* title = NULL,
|
||||||
bool editbutton = TRUE,
|
bool editbutton = TRUE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user