From 6f0963cb41c79a10211826c0e052fcafeab75bc0 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 12 May 1995 09:24:47 +0000 Subject: [PATCH] Aggiunta gestione posizioni di tabulazione per stampe con caratteri proporzionali. Gestione configurazioni di stampa applicazione per applicazione se necessaria. git-svn-id: svn://10.65.10.50/trunk@1360 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/config.cpp | 10 +- include/config.h | 3 +- include/default.url | 2 +- include/printer.cpp | 216 ++++++++++++++++++++++++++++++------------- include/printer.h | 16 +++- include/printwin.cpp | 36 ++++---- include/text.cpp | 82 ++++++++-------- include/text.h | 13 ++- 8 files changed, 235 insertions(+), 143 deletions(-) diff --git a/include/config.cpp b/include/config.cpp index d2f276c65..c2a46c940 100755 --- a/include/config.cpp +++ b/include/config.cpp @@ -286,6 +286,7 @@ TConfig::TConfig(int which_config, const char* paragraph) _file = "prassis.ini"; break; case CONFIG_USER: + case CONFIG_STAMPE: _file = main_app().get_firm_dir(); if (_file.not_empty()) { @@ -296,7 +297,7 @@ TConfig::TConfig(int which_config, const char* paragraph) _file << "config"; if (!fexist(_file)) make_dir(_file); - _file << '/' << user() << ".ini"; + _file << '/' << (which_config == CONFIG_USER ? user() : "print") << ".ini"; break; case CONFIG_FCONV: _file = "fconv.ini"; @@ -306,13 +307,6 @@ TConfig::TConfig(int which_config, const char* paragraph) break; } - if (!fexist(_file)) - { - FILE* c = fopen(_file, "w"); - CHECKS(c, "Impossibile aprire il file di configurazione %s", (const char*)_file); - fclose(c); - } - init(_file, paragraph); } diff --git a/include/config.h b/include/config.h index 6952047d4..b38fb5af6 100755 --- a/include/config.h +++ b/include/config.h @@ -21,7 +21,8 @@ class ofstream; #define CONFIG_FCONV 3 // file parametri utente #define CONFIG_USER 4 - +// file parametri stampe +#define CONFIG_STAMPE 5 class TConfig : public TObject { diff --git a/include/default.url b/include/default.url index 78ca71530..bcdc9a880 100755 --- a/include/default.url +++ b/include/default.url @@ -1,7 +1,7 @@ #ifndef APPNAME #define APPNAME PRASSI #define QAPPNAME "PRASSI" -#define LIBDIR f:\xvt.45b\w16_x86\ptk\lib +#define LIBDIR f:\xvt.403\win_x86\ptk\lib #endif #define NO_STD_EDIT_MENU diff --git a/include/printer.cpp b/include/printer.cpp index 2638240bc..28b8ca1fe 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -443,13 +443,18 @@ word TPrintrow::class_id() TPrintrow & TPrintrow::reset () { - _row.spaces (sizeof (_attr)); + _row.spaces (sizeof (_attr)); // Azzera testo + + memset (_attr, normalstyle, sizeof (_attr)); // Azzera stile + + _tab.reset(); // Azzera tabulazioni + _currentcolor = 'w'; _currentcolor <<= 8; _currentcolor += 'n'; - memset (_attr, normalstyle, sizeof (_attr)); for (int i = 0; i < MAXSTR; i++) - _cols[i] = _currentcolor; + _cols[i] = _currentcolor; // Azzera colori + _lastpos = 0; _currentstyle = normalstyle; return *this; @@ -467,6 +472,12 @@ const char* TPrintrow::row_codified() const for (i = 0; i < _row.size(); i++) { + if (_tab[i]) + { + __tmp_string[k++] = '@'; + __tmp_string[k++] = 't'; + } + if (_attr[i] != last_attr) { __tmp_string[k++] = '@'; @@ -510,12 +521,10 @@ TPrintrow & TPrintrow::put(const char *str, int position, int len) if (len < 1) len = strlen (str); - bool jumped = TRUE; if (position < 0) - { position = _lastpos; - jumped = FALSE; - } + else + _tab.set(position); char bg = 'w', fg = 'n'; for (int i = 0; i < len; i++) @@ -594,6 +603,7 @@ TPrintrow & TPrintrow::put(const char *str, int position, int len) _cols[k] = _currentcolor; } position = pp; + _tab.set(position); } else if (toupper (c) == 'J') { @@ -605,6 +615,7 @@ TPrintrow & TPrintrow::put(const char *str, int position, int len) _cols[k + position] = _currentcolor; } position += pp; + _tab.set(position); } } else @@ -704,29 +715,44 @@ void TPrinter::set_win_formlen(WINDOW prwin) HIDDEN bool set_windows_print_device (TMask_field& f, KEY key) { if (key == K_SPACE) - { + { + main_app().begin_wait(); TPrinter& pr = printer(); - TToken_string& pn = pr.getprinternames (); - TString80 pdev (pn.get(atoi (f.get()))); // Nome stampante corrente - - char szDevice[80]; - GetProfileString ("devices", pdev, "", szDevice, sizeof (szDevice)); - pdev << "," << szDevice; + if (f.dirty()) + { + TToken_string& pn = pr.getprinternames (); + TString80 pdev (pn.get(atoi (f.get()))); // Nome stampante corrente + + char szDevice[80]; + GetProfileString ("devices", pdev, "", szDevice, sizeof (szDevice)); + pdev << "," << szDevice; - // scrivi (e semmai lo si risistema poi) - WriteProfileString("windows", "device", pdev); - pr.set_printrcd(); - pr.set_win_formlen(); + // scrivi (e semmai lo si risistema poi) + WriteProfileString("windows", "device", pdev); + pr.set_printrcd(); + pr.set_win_formlen(); + } const int MAX_FAMILIES = 128; char* family[MAX_FAMILIES]; const int num_families = (int)xvt_fmap_get_families(pr.get_printrcd(), family, MAX_FAMILIES); TToken_string pn1(256), pn2(256); + + const int MAXSIZES = 16; + long sizes[MAXSIZES]; + BOOLEAN scalable; + for (int i = 0; i < num_families; i++) { - pn1.add(family[i]); - pn2.add(family[i]); + const int num_sizes = (int)xvt_fmap_get_family_sizes(pr.get_printrcd(), + family[i], sizes, &scalable, MAXSIZES); + if (num_sizes > 0) + { + pn1.add(family[i]); + pn2.add(family[i]); + } + xvt_mem_free(family[i]); } TMask& m = f.mask(); @@ -734,6 +760,8 @@ HIDDEN bool set_windows_print_device (TMask_field& f, KEY key) lst.replace_items(pn1, pn2); lst.set(printer().fontname()); + + main_app().end_wait(); } return TRUE; } @@ -742,8 +770,10 @@ HIDDEN bool font_handler(TMask_field& f, KEY key) { if (key == K_SPACE) { + main_app().begin_wait(); + const char* family = f.get(); - const int MAXSIZES = 32; + const int MAXSIZES = 16; long sizes[MAXSIZES]; BOOLEAN scalable; const int num_sizes = (int)xvt_fmap_get_family_sizes(printer().get_printrcd(), @@ -765,9 +795,10 @@ HIDDEN bool font_handler(TMask_field& f, KEY key) } TList_field& lst = (TList_field&)f.mask().field(MSK_1_SIZE); - const TString16 old(lst.get()); lst.replace_items(pn1, pn2); - lst.set(old); + lst.set(format("%d", printer().get_char_size())); + + main_app().end_wait(); } return TRUE; } @@ -837,8 +868,10 @@ TToken_string& TPrinter::getprinternames () return _printer_names; } -void TPrinter::read_configuration() -{ +void TPrinter::read_configuration(const char* parag) +{ + main_app().begin_wait(); + #if XVT_OS == XVT_OS_SCOUNIX const char* const config = "printer.ini"; FILE *cnfp = fopen (config, "r"); @@ -874,16 +907,46 @@ void TPrinter::read_configuration() #endif - TConfig prini(CONFIG_USER, "Printer"); + _config = parag; + if (_config.empty()) + _config = "Printer"; + + TConfig* iniptr = NULL; + if (_config != "Printer") + { + iniptr = new TConfig(CONFIG_STAMPE, _config); + if (!iniptr->exist("Type")) + { + delete iniptr; iniptr = NULL; + } + } + if (iniptr == NULL) + iniptr = new TConfig(CONFIG_USER, "Printer"); + + const int what = iniptr->get_int("Type", NULL, -1, 0); // Tipo stampante + _curprn = iniptr->get_int("Number", NULL, -1, 0); // Numero stampante corrente + _printerfile = iniptr->get("File", NULL, -1, ""); // File di stampa + _curcode = iniptr->get_int("Codes", NULL, -1, 0); // Codici di stampa + _fontname = iniptr->get("Font", NULL, -1, XVT_FFN_FIXED); // Nome del font + _ch_size = iniptr->get_int("Size", NULL, -1, 12); // Dimensione del font + _lines_per_inch = iniptr->get_int("Lines", NULL, -1, 6); // Linee per pollice + _isgraphics = iniptr->get_bool("Graphic", NULL, -1, FALSE); // Grafica attiva - const int what = prini.get_int("Type", NULL, -1, 0); // Tipo stampante - _curprn = prini.get_int("Number", NULL, -1, 0); // Numero stampante corrente - _printerfile = prini.get("File", NULL, -1, ""); // File di stampa - _curcode = prini.get_int("Codes", NULL, -1, 0); // Codici di stampa - _fontname = prini.get("Font", NULL, -1, XVT_FFN_FIXED); // Nome del font - _ch_size = prini.get_int("Size", NULL, -1, 12); // Dimensione del font - _lines_per_inch = prini.get_int("Lines", NULL, -1, 6); // Linee per pollice - _isgraphics = prini.get_bool("Graphic", NULL, -1, FALSE); // Grafica attiva + if (iniptr->exist("rcd", 0)) + { + int size, i = 0; + byte* rcd = (byte*)get_printrcd(&size); + + TToken_string s(256); + for (int index = 0; i < size; index++) + { + s = iniptr->get("rcd", NULL, index); + for (const char* n = s.get(0); n; n = s.get()) + rcd[i++] = (byte)atoi(n); + } + } + + delete iniptr; iniptr = NULL; if (_printerfile.empty()) { @@ -898,6 +961,7 @@ void TPrinter::read_configuration() switch (what) { case 0: + case 5: #if XVT_OS == XVT_OS_WIN _printertype = winprinter; #else @@ -925,7 +989,48 @@ void TPrinter::read_configuration() break; default: break; - } + } + + main_app().end_wait(); +} + + +void TPrinter::save_configuration() +{ + main_app().begin_wait(); + + CHECK(_config.not_empty(), "Invalid printer config"); + TConfig prini(_config == "Printer" ? CONFIG_USER : CONFIG_STAMPE, _config); + + prini.set("Type", _printertype); // Tipo stampante + prini.set("Number", _curprn); // Numero stampante corrente + prini.set("File", _printerfile); // File di stampa + prini.set("Codes", _curcode); // Codici di stampa + prini.set("Font", _fontname); // Nome del font + prini.set("Size", _ch_size); // Dimensione del font + prini.set("Lines", _lines_per_inch); // Linee per pollice + prini.set("Graphic", _isgraphics ? "X" : ""); // Grafica attiva + + int n = 0, index = 0; + TToken_string val(256); + + int rcdsize; + byte* rcd = (byte*)get_printrcd(&rcdsize); + + for (int i = 0; i < rcdsize; i++) + { + val.add((int)rcd[i]); + n++; + if (n == 24) + { + prini.set("rcd", val, NULL, TRUE, index++); + val.cut(n = 0); + } + } + if (n > 0) + prini.set("rcd", val, NULL, TRUE, index); + + main_app().end_wait(); } TPrinter::~TPrinter () @@ -1304,7 +1409,8 @@ void TPrinter::set() int i; mask.set(MSK_1_FILENAME, _printerfile); - mask.set(MSK_1_NPAGES, _ncopies); + mask.set(MSK_1_NPAGES, _ncopies); + mask.enable(DLG_OK, _config == "Printer"); #if XVT_OS == XVT_OS_SCOUNIX @@ -1343,13 +1449,9 @@ void TPrinter::set() mask.show(MSK_1_CODES); mask.set(MSK_1_CODES, _curcode); - KEY k; + KEY k = mask.run(); - if ((k = mask.run()) == K_ESC) - return; - - if (k == K_INS) // premuto REGISTRA - mask.save(); + if (k == K_ESC) return; // get user choices @@ -1436,8 +1538,7 @@ void TPrinter::set() _curprn = pn2.get_pos(name); CHECKS(_curprn >= 0, "Can't find printer ", name); mask.set(MSK_1_PRINTERS, pn1.get(_curprn)); - - set_win_formlen(); // Update dimensions + // set_win_formlen(); // Update dimensions } else beep (); @@ -1487,21 +1588,11 @@ void TPrinter::set() _isgraphics = mask.get_bool (MSK_1_ISGRAPHICS); set_win_formlen (); - if (k == K_INS) - { - TConfig prini(CONFIG_USER, "Printer"); - prini.set("Type", _printertype); // Tipo stampante - prini.set("Number", _curprn); // Numero stampante corrente - prini.set("File", _printerfile); // File di stampa - prini.set("Codes", _curcode); // Codici di stampa - prini.set("Font", _fontname); // Nome del font - prini.set("Size", _ch_size); // Dimensione del font - prini.set("Lines", _lines_per_inch); // Linee per pollice - prini.set("Graphic", _isgraphics ? "X" : ""); // Grafica attiva - } - #endif + if (k == K_INS) + save_configuration(); + main_app().enable_menu_item (M_FILE_PG_SETUP); } @@ -1635,16 +1726,15 @@ _isopen = FALSE; #include -#if XVT_OS == XVT_OS_DOS -#define FORMAT_COMMAND "FORMAT" +#if XVT_OS == XVT_OS_WIN +const char* const FORMAT_COMMAND = "FORMAT"; #else -#define FORMAT_COMMAND "dosformat -fq" +const char* const FORMAT_COMMAND = "dosformat -fq"; #endif -const long disk_sizes[] = -{360000, 1200000, 720000, 1400000, 2880000}; +const long disk_sizes[] = { 360000L, 1200000L, 720000L, 1400000L, 2880000L }; -TFile_printer ::TFile_printer (const char *ffile, const char *label, int len_rec, int num_rec_inizio, int num_rec_fine, int tipo_disco) +TFile_printer::TFile_printer (const char *ffile, const char *label, int len_rec, int num_rec_inizio, int num_rec_fine, int tipo_disco) { set_printtype (fileprinter); diff --git a/include/printer.h b/include/printer.h index 8ba82b77b..183de1166 100755 --- a/include/printer.h +++ b/include/printer.h @@ -20,11 +20,11 @@ enum TPrintstyle normalstyle = 0, boldstyle = 1, underlinedstyle = 2, - italicstyle = 4, - jumpstyle = 64 + italicstyle = 4 }; -enum TPrtype { +enum TPrtype +{ normprinter = 0, fileprinter = 1, spoolprinter = 2, @@ -49,6 +49,8 @@ class TPrintrow : public TObject TString256 _row; // the actual string to print char _attr[MAXSTR]; // contains char attributes of _row int _cols[MAXSTR]; // contains color attributes of _row + TBit_array _tab; + TPrintstyle _currentstyle; // the current char attribute int _currentcolor; // the current color attribute int _lastpos; // last print position @@ -159,7 +161,8 @@ class TPrinter : public TObject TArray _linksdescr; TArray _bookmarks; // bookmarks bool _multiple_link; // - + + TString _config; // Nome del paragrafo di configurazione TString_array _background; TString_array _image_names; @@ -193,11 +196,12 @@ protected: virtual char newline() { return '\n'; } bool printrow (TPrintrow* rowtoprint=NULL); // base methods for printing bool printformfeed (); - void read_configuration(); bool printheader(); bool printfooter(); + void save_configuration(); + public: // @FPUB @@ -309,6 +313,8 @@ public: int get_char_size() const { return _ch_size; } char* fontname() const { return (char*)(const char*)_fontname; } + void read_configuration(const char* parag = NULL); + // bookmarks int set_bookmark(const char* txt, int father = -1); }; diff --git a/include/printwin.cpp b/include/printwin.cpp index 50ad47c2e..bb541f65e 100755 --- a/include/printwin.cpp +++ b/include/printwin.cpp @@ -13,7 +13,7 @@ HIDDEN int LEN_SPACES(WINDOW win, int x) } if (w == 0L) { - TString256 spc; spc.fill('M', 132); + TString256 spc; spc.fill('m', 132); w = xvt_dwin_get_text_width(win,(char*)(const char*)spc, 132); } const int k = int((w*x) / 132); @@ -22,7 +22,7 @@ HIDDEN int LEN_SPACES(WINDOW win, int x) static bool error_on = TRUE; if (error_on) { - TString256 spc; spc.fill('M', x); + TString256 spc; spc.fill('m', x); const int k1 = xvt_dwin_get_text_width(win,(char*)(const char*)spc,x); if (k != k1) error_on = error_box("Maguire disagrees: %d != %d", k, k1); @@ -171,29 +171,27 @@ void TPrintwin::paint_row(long j) while((cp = _txt.piece()) != NULL) { #if XVT_OS != XVT_OS_SCOUNIX - int st = _txt.get_style(); - long bg = trans_color(_txt.get_background()); - long fg = trans_color(_txt.get_foreground()); + const int st = _txt.get_style(); set_font(printer().fontname(), st, _char_size); - set_color(fg,bg); + + const COLOR bg = trans_color(_txt.get_background()); + const COLOR fg = trans_color(_txt.get_foreground()); + set_color(fg, bg); #else set_color(COLOR_BLACK, COLOR_WHITE); -#endif +#endif - const char* end = NULL; - for (const char* begin = cp; *begin; begin = end) - { - for (; *begin == ' '; begin++) - pos++; - + const char* beg = cp; + while (*beg) + { int len = 0; - for (end = begin; *end > ' ' || (*end && *(end+1) > ' '); end++) - len++; - - if (*begin > ' ') - xvt_dwin_draw_text(win(), _hofs + LEN_SPACES(win(), pos), y, (char*)begin, len); - + for (; *beg == ' '; beg++) // Salta spazi iniziali + pos++; + for (const char* end = beg; *end > ' ' || (*end && *(end+1) > ' '); end++) + len++; // Misura sringa da stampare + xvt_dwin_draw_text(win(), _hofs + LEN_SPACES(win(), pos), y, (char*)beg, len); pos += len; + beg = end; } } } diff --git a/include/text.cpp b/include/text.cpp index a402fbc1e..3018246db 100755 --- a/include/text.cpp +++ b/include/text.cpp @@ -3,7 +3,7 @@ #include #include -static char mytmpstr[257]; +static char TEXT_TMP[257]; class _HotSpot : public TObject { @@ -33,19 +33,16 @@ style TTextfile::_trans_style (char ch) { case 'r': return normal; - break; case 'i': return italic; - break; case 'b': return bold; - break; case 'u': return underlined; - break; + case 't': + return tabbed; default: return normal; - break; } } @@ -84,7 +81,7 @@ void TTextfile::_save_changes() freeze (); } - if (fgets(mytmpstr, sizeof(mytmpstr), _instr) == NULL) + if (fgets(TEXT_TMP, sizeof(TEXT_TMP), _instr) == NULL) break; if (line >= _page_start && line <= _page_end) @@ -92,12 +89,12 @@ void TTextfile::_save_changes() TString& lin = (TString&)(_page[(int)(line - _page_start)]); if (_dirty_lines[line - _page_start]) { - strcpy(mytmpstr, lin); - strcat(mytmpstr, "\n"); + strcpy(TEXT_TMP, lin); + strcat(TEXT_TMP, "\n"); } } - fprintf(newf, "%s", mytmpstr); + fprintf(newf, "%s", TEXT_TMP); line++; } @@ -153,10 +150,10 @@ void TTextfile::_read_page (long n) { if (feof (_instr)) break; - fgets (mytmpstr, sizeof (mytmpstr), _instr); - mytmpstr[strlen (mytmpstr) - 1] = '\0'; + fgets (TEXT_TMP, sizeof (TEXT_TMP), _instr); + TEXT_TMP[strlen (TEXT_TMP) - 1] = '\0'; TString & ts = (TString &) _page[(int) (i - _page_start)]; - ts = mytmpstr; + ts = TEXT_TMP; TString hcol (6); // find hotspots and compile list @@ -216,16 +213,17 @@ void TTextfile::read_line (long n, long pos, bool pg) if (!first && p >= pos) { _styles[_item++] = stl; - mytmpstr[ndx] = '\0'; - _line.add (mytmpstr); + TEXT_TMP[ndx] = '\0'; + _line.add (TEXT_TMP); ndx = 0; } while (ch && (ch == '@' || (ch == '$' && *sp == '['))) { if (ch == '@') // font style change ? - - { - style sss = _trans_style (*sp++); + { + const char c = *sp++; + + style sss = _trans_style (c); if (sss == normal) stl = (long) col << 16; else @@ -251,13 +249,13 @@ void TTextfile::read_line (long n, long pos, bool pg) if (ch && p >= pos) { first = FALSE; - mytmpstr[ndx++] = ch; + TEXT_TMP[ndx++] = ch; } p++; } _styles[_item++] = stl; - mytmpstr[ndx] = '\0'; - _line.add(mytmpstr); + TEXT_TMP[ndx] = '\0'; + _line.add(TEXT_TMP); _item = 0; } @@ -265,16 +263,16 @@ const char *TTextfile::line(long j, long pos, int howmuch) { if (_cur_line != j) read_line (j); - *mytmpstr = '\0'; + *TEXT_TMP = '\0'; _line.restart (); for (int i = 0; i < _line.items (); i++) - strcat (mytmpstr, (const char *) _line.get ()); + strcat (TEXT_TMP, (const char *) _line.get ()); if (howmuch != -1) { - if (((unsigned int)pos+howmuch) < strlen(mytmpstr)) - mytmpstr[pos+howmuch] = '\0'; + if (((unsigned int)pos+howmuch) < strlen(TEXT_TMP)) + TEXT_TMP[pos+howmuch] = '\0'; } - return strlen(mytmpstr) > (word)pos ? &(mytmpstr[pos]) : ""; + return strlen(TEXT_TMP) > (word)pos ? &(TEXT_TMP[pos]) : ""; } @@ -345,8 +343,8 @@ const char *TTextfile::line_formatted(long j) if (_cur_line != j) read_line (j); TString* tp = (TString*)_page.objptr(int(j-_page_start)); - strcpy(mytmpstr, (const char*)(*tp)); - return mytmpstr; + strcpy(TEXT_TMP, (const char*)(*tp)); + return TEXT_TMP; } long TTextfile::get_attribute (int pos) @@ -362,7 +360,7 @@ long TTextfile::get_attribute (int pos) int x = 0, nd = 0; const char *c; _line.restart (); - while (c = _line.get ()) + while ((c = _line.get ()) != NULL) { x += strlen (c); stl = _styles[nd++]; @@ -375,7 +373,7 @@ long TTextfile::get_attribute (int pos) int TTextfile::get_style (int pos) { - long x = get_attribute (pos); + const long x = get_attribute(pos) & ~tabbed; return (int) (x & 0x0000ffff); } @@ -391,11 +389,13 @@ char TTextfile::get_foreground (int pos) return (char) ((x >> 16) & 0x000000ff); } -const char *TTextfile::piece () -{ - if (_item >= _line.items ()) +const char* TTextfile::piece() +{ + const char* l = _line.get(_item); + if (l == NULL) return NULL; - return strcpy (mytmpstr, (const char *) _line.get (_item++)); + _item++; + return strcpy(TEXT_TMP, l); } const char *TTextfile::word_at (long x, long y) @@ -419,10 +419,10 @@ const char *TTextfile::word_at (long x, long y) break; } while (isalnum (s[(int) x])) - mytmpstr[x2++] = s[(int) x++]; + TEXT_TMP[x2++] = s[(int) x++]; } - mytmpstr[x2] = '\0'; - return mytmpstr; + TEXT_TMP[x2] = '\0'; + return TEXT_TMP; } bool TTextfile::append (const char *l) @@ -596,13 +596,13 @@ _hotspots (4), _accept (TRUE), _dirty_lines(pagesize) error_box("Errore di scrittura file temporaneo: scrittura interrotta"); freeze(); } - if (fgets (mytmpstr, sizeof (mytmpstr), _instr) == NULL) + if (fgets (TEXT_TMP, sizeof (TEXT_TMP), _instr) == NULL) break; - if (mytmpstr[strlen(mytmpstr)-1] == '\n') - mytmpstr[strlen(mytmpstr)-1] = '\0'; + 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 (mytmpstr); + TString *ll = new TString (TEXT_TMP); _page.add(ll); _page_end++; diff --git a/include/text.h b/include/text.h index e3aedd093..5851494d2 100755 --- a/include/text.h +++ b/include/text.h @@ -16,7 +16,8 @@ enum direction {up, down, updown}; -enum style {normal = XVT_FS_NONE, bold = XVT_FS_BOLD, italic = XVT_FS_ITALIC, underlined = XVT_FS_UNDERLINE }; +enum style {normal = XVT_FS_NONE, bold = XVT_FS_BOLD, italic = XVT_FS_ITALIC, + underlined = XVT_FS_UNDERLINE, tabbed = XVT_FS_SCALE }; class TTextfile: public TObject { @@ -34,9 +35,12 @@ class TTextfile: public TObject FILE* _index; FILE* _instr; direction _direction; - TToken_string _line; - long _styles[256]; - int _item; + + int _item; // Piece corrente + TToken_string _line; // Testo riga corrente + long _styles[256]; // Stile e colore carattere + bool _tabbed_piece; + TArray _hotspots; TArray _spots; bool _dirty; @@ -88,7 +92,6 @@ public: int get_style(int pos = -1); char get_background(int pos = -1); char get_foreground(int pos = -1); - long get_attribute(int pos = -1); // ritorna la parola alla posizione indicata