Corretto destinatario TMessage

MOdificati sheet in modo da gestire meglio perdita e guadagno del focus
Tolta isspace dalle TString e messa is_space


git-svn-id: svn://10.65.10.50/trunk@869 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-01-16 15:10:52 +00:00
parent 4510dcba25
commit 0a93dba34d
14 changed files with 398 additions and 374 deletions

View File

@ -130,9 +130,9 @@ void TBanner::handler(WINDOW win, EVENT* ep)
r.left += 4; r.right -= 4; r.left += 4; r.right -= 4;
r.top += 4; r.bottom -= 4; r.top += 4; r.bottom -= 4;
set_pen(COLOR_BLACK); win_draw_rect(win, &r);
offset_rect(&r, 1, 1);
set_pen(COLOR_WHITE); win_draw_rect(win, &r); set_pen(COLOR_WHITE); win_draw_rect(win, &r);
offset_rect(&r, -1, -1);
set_pen(COLOR_BLACK); win_draw_rect(win, &r);
win_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC); win_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC);
} }
@ -650,10 +650,7 @@ void TApplication::set_cursor(bool w)
else else
{ {
_count--; _count--;
#ifdef DBG CHECK(_count >= 0, "end_wait without matching begin_wait");
if (_count < 0)
yesnofatal_box("end_wait without matching begin_wait");
#endif
if (_count == 0) if (_count == 0)
::set_cursor(ww, CURSOR_ARROW); ::set_cursor(ww, CURSOR_ARROW);
} }

View File

@ -122,7 +122,7 @@ TString& TConfig::get(const char* var, const char* section, int index, const cha
{ {
// ritorna valore di variabile nella sezione corrente o in // ritorna valore di variabile nella sezione corrente o in
// quella specificata // quella specificata
static TFixed_string s(__tmp_string, 256); static TFixed_string s(&__tmp_string[256], 256);
TString80 vvar(var); if (index != -1) vvar << '(' << index << ')'; TString80 vvar(var); if (index != -1) vvar << '(' << index << ')';
_check_paragraph(section); _check_paragraph(section);

View File

@ -689,7 +689,6 @@ int TLocalisamfile::open(unsigned int mode)
err = _open(); err = _open();
_was_open = TRUE; _was_open = TRUE;
} }
_isatab = FALSE;
setstatus(err); setstatus(err);
return err; return err;
} }

View File

@ -379,7 +379,6 @@ class TLocalisamfile : public TBaseisamfile
{ {
// @DPRIV // @DPRIV
bool _was_open; // Vero se il file e' stato aperto come Localisamfile bool _was_open; // Vero se il file e' stato aperto come Localisamfile
bool _isatab; // Vero se il file e' una tabella
int _oldkey; // Old key if already open int _oldkey; // Old key if already open
public: public:

View File

@ -1,4 +1,4 @@
// $Id: mailbox.cpp,v 1.10 1994-12-15 18:06:18 guy Exp $ // $Id: mailbox.cpp,v 1.11 1995-01-16 15:10:23 guy Exp $
#include <stdlib.h> #include <stdlib.h>
#include <fstream.h> #include <fstream.h>
@ -19,9 +19,10 @@
TMessage::TMessage(const char* to, const char* sub, TMessage::TMessage(const char* to, const char* sub,
const char* text, const char* from) const char* text, const char* from)
{ {
_to = to; TString80 rec(to);
if (to && *to && (_to.len() != 6 || _to.strip(" -") != to)) if (rec.not_empty() && (rec.len() != 6 || rec.strip(" -") != to))
_to = cmd2name(to); rec = cmd2name(to);
_to = rec;
_subject = sub; _subject = sub;
_text = text; _text = text;
_from = (from == NULL || *from == '\0') ? main_app().name() : from; _from = (from == NULL || *from == '\0') ? main_app().name() : from;

View File

@ -1,4 +1,4 @@
// $Id: mailbox.h,v 1.4 1994-10-24 15:06:27 guy Exp $ // $Id: mailbox.h,v 1.5 1995-01-16 15:10:24 guy Exp $
/* si', trattasi di -*-c++-*- */ /* si', trattasi di -*-c++-*- */
// Mailbox.h // Mailbox.h
@ -7,10 +7,6 @@
#ifndef __MAILBOX_H #ifndef __MAILBOX_H
#define __MAILBOX_H #define __MAILBOX_H
#ifndef __ARRAY_H
#include <array.h>
#endif
#ifndef __STRINGS_H #ifndef __STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif

View File

@ -26,11 +26,11 @@ bool TMask::test_focus_change(WINDOW next)
TMask_field& prev = fld(_focus); TMask_field& prev = fld(_focus);
if (prev.win() != next) if (prev.win() != next)
{ {
if (prev.on_key(K_TAB) == FALSE) // Test if previous field agrees ... ok = prev.test_focus_change();
if (!ok) // Test if previous field agrees ...
{ {
set_focus(); set_focus();
prev.set_focusdirty(FALSE); prev.set_focusdirty(FALSE);
ok = FALSE; // ... sorry, it does not
} }
} }
return ok; return ok;
@ -132,11 +132,17 @@ void TMask::handler(WINDOW win, EVENT* ep)
switch(ep->v.ctl.id) switch(ep->v.ctl.id)
{ {
case DLG_OK: case DLG_OK:
if (test_focus_change()) stop_run(K_AUTO_ENTER); break; if (test_focus_change(ep->v.ctl.ci.win))
stop_run(K_AUTO_ENTER);
break;
case DLG_CANCEL : case DLG_CANCEL :
stop_run(K_ESC); break; if (test_focus_change(ep->v.ctl.ci.win))
stop_run(K_ESC);
break;
case DLG_QUIT : case DLG_QUIT :
stop_run(K_FORCE_CLOSE); break; if (test_focus_change(ep->v.ctl.ci.win))
stop_run(K_FORCE_CLOSE);
break;
case DLG_F9: case DLG_F9:
{ {
WINDOW w = ep->v.ctl.ci.win; WINDOW w = ep->v.ctl.ci.win;

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.67 1995-01-05 17:50:24 guy Exp $ // $Id: maskfld.cpp,v 1.68 1995-01-16 15:10:31 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -722,6 +722,15 @@ bool TMask_field::do_message(int num)
} }
bool TMask_field::test_focus_change()
{
bool ok = TRUE;
if (focusdirty())
ok = on_key(K_TAB);
return ok;
}
// Certified 90% // Certified 90%
bool TMask_field::on_hit() bool TMask_field::on_hit()
{ {

View File

@ -1,4 +1,4 @@
/* $Id: maskfld.h,v 1.19 1994-12-30 10:11:11 villa Exp $ */ /* $Id: maskfld.h,v 1.20 1995-01-16 15:10:36 guy Exp $ */
#ifndef __MASKFLD_H #ifndef __MASKFLD_H
#define __MASKFLD_H #define __MASKFLD_H
@ -121,6 +121,7 @@ public:
bool focusdirty() const { return _flags.focusdirty; } bool focusdirty() const { return _flags.focusdirty; }
void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; } void set_focusdirty(bool d = TRUE) { _flags.focusdirty = d; }
void set_dirty(bool d = TRUE); void set_dirty(bool d = TRUE);
void set_justify(bool r) { _flags.rightjust = r; }
virtual const char* class_name() const; virtual const char* class_name() const;
virtual word class_id() const; virtual word class_id() const;
@ -162,6 +163,7 @@ public:
virtual bool on_hit(); virtual bool on_hit();
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
virtual bool test_focus_change();
void set(const char* s); void set(const char* s);
TString& get() const; TString& get() const;

View File

@ -96,6 +96,7 @@ public:
void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork); } void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork); }
bool active() const { return _active; } bool active() const { return _active; }
bool test_focus_change();
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; } void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
@ -363,11 +364,19 @@ void TSpreadsheet::update_rec(int rec)
void TSpreadsheet::set_focus_cell(int riga, int colonna) void TSpreadsheet::set_focus_cell(int riga, int colonna)
{ {
set_front_window(win()); // It seems necessary to make xi_set_focus work properly set_front_window(win()); // It seems necessary
const int r = rec2row(riga); const int r = rec2row(riga);
for (; colonna < _columns; colonna++)
if (!cell_disabled(r, colonna-1))
break;
if (colonna < _columns)
{
XI_OBJ cell; XI_OBJ cell;
XI_MAKE_CELL(&cell, _list, r, colonna); XI_MAKE_CELL(&cell, _list, r, colonna);
xi_set_focus(&cell); xi_set_focus(&cell);
}
} }
@ -428,10 +437,23 @@ void TSpreadsheet::notify_change()
{ {
notify(_cur_rec, K_SPACE); notify(_cur_rec, K_SPACE);
_row_dirty = TRUE; _row_dirty = TRUE;
set_dirty();
} }
} }
bool TSpreadsheet::test_focus_change()
{
bool ok = dirty() != 3;
if (ok && _row_dirty)
{
str2mask(selected());
ok = sheet_mask().check_fields();
}
return ok;
}
void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev) void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev)
{ {
TSpreadsheet* es = (TSpreadsheet*)xi_get_app_data(itf); TSpreadsheet* es = (TSpreadsheet*)xi_get_app_data(itf);
@ -439,6 +461,7 @@ void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev)
es->list_handler(xiev); es->list_handler(xiev);
} }
// Certified 75% // Certified 75%
void TSpreadsheet::list_handler(XI_EVENT *xiev) void TSpreadsheet::list_handler(XI_EVENT *xiev)
{ {
@ -448,33 +471,30 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
switch (xiev->type) switch (xiev->type)
{ {
case XIE_GET_FIRST: case XIE_GET_FIRST:
if (items() > 0L)
{ {
const long max = items(); long n = items() * (long)xiev->v.rec_request.percent / 100L;
if (max > 0L)
{
long n = max * (long)xiev->v.rec_request.percent / 100L;
if (n < 0L) n = 0L; if (n < 0L) n = 0L;
xiev->v.rec_request.data_rec = n; xiev->v.rec_request.data_rec = n;
} }
else else
xiev->refused = TRUE; xiev->refused = TRUE;
}
break; break;
case XIE_GET_LAST: case XIE_GET_LAST:
xiev->v.rec_request.data_rec = items()-1; xiev->v.rec_request.data_rec = items()-1;
break; break;
case XIE_GET_PREV: case XIE_GET_PREV:
case XIE_GET_NEXT: case XIE_GET_NEXT:
{ {
const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ; const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ;
if (n < 0 || n >= items()) if (n < 0 || n >= items())
xiev->refused = TRUE; xiev->refused = TRUE;
else else
xiev->v.rec_request.data_rec = n; xiev->v.rec_request.data_rec = n;
} }
break; break;
case XIE_CELL_REQUEST: case XIE_CELL_REQUEST:
{ {
const int rec = (int)xiev->v.cell_request.rec; const int rec = (int)xiev->v.cell_request.rec;
const char* src = NULL; const char* src = NULL;
int nm; int nm;
@ -518,14 +538,11 @@ break;
const int len = xiev->v.cell_request.len; const int len = xiev->v.cell_request.len;
char* dst = xiev->v.cell_request.s; char* dst = xiev->v.cell_request.s;
if (src) if (src)
{
strncpy(dst, src, len); strncpy(dst, src, len);
// if (isspace(*dst)) { TFixed_string d(dst); d.ltrim(); } TBR
}
else else
*dst = '\0'; *dst = '\0';
} }
break; break;
case XIE_CHG_CELL: case XIE_CHG_CELL:
notify_change(); notify_change();
_cell_dirty = TRUE; _cell_dirty = TRUE;
@ -539,7 +556,7 @@ break;
break; break;
case XIE_SELECT: case XIE_SELECT:
if (xiev->v.xi_obj->type == XIT_ROW) if (xiev->v.xi_obj->type == XIT_ROW)
{ {
_check_enabled = FALSE; _check_enabled = FALSE;
const int oldrec = _cur_rec; const int oldrec = _cur_rec;
@ -558,11 +575,11 @@ break;
mask2str(_cur_rec); mask2str(_cur_rec);
_check_enabled = TRUE; _check_enabled = TRUE;
} }
xiev->refused = TRUE; xiev->refused = TRUE;
break; break;
case XIE_DBL_CELL: case XIE_DBL_CELL:
{ {
_check_enabled = FALSE; _check_enabled = FALSE;
const int oldrec = _cur_rec; const int oldrec = _cur_rec;
@ -580,25 +597,25 @@ break;
_row_dirty = TRUE; _row_dirty = TRUE;
} }
if (!cell_disabled(_cur_rec, _cur_col)) if (!cell_disabled(_cur_rec, _cur_col-1))
set_focus_cell(_cur_row, _cur_col); set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; _check_enabled = TRUE;
} }
break; break;
case XIE_ON_LIST: case XIE_ON_LIST:
if (_firstfocus) // Trick to avoid the sheet to keep the focus forever ... if (_firstfocus) // Trick to avoid the sheet to keep the focus forever ...
{ // .. it costed me two day worth of hard work! { // .. it costed me two day worth of hard work!
xiev->refused = TRUE; xiev->refused = TRUE;
_firstfocus = FALSE; _firstfocus = FALSE;
} }
else else
mask().set_focus_win(win(), FALSE); mask().set_focus_win(win(), FALSE);
break; break;
case XIE_OFF_LIST: case XIE_OFF_LIST:
break; break;
case XIE_ON_ROW: case XIE_ON_ROW:
if (_check_enabled) if (_check_enabled)
{ {
set_pos(xiev->v.xi_obj->v.row, _cur_col); set_pos(xiev->v.xi_obj->v.row, _cur_col);
if (_cur_rec < items()) if (_cur_rec < items())
{ {
@ -610,11 +627,11 @@ break;
_cur_row = _cur_rec = 0; _cur_row = _cur_rec = 0;
xiev->refused = TRUE; xiev->refused = TRUE;
} }
} }
break; break;
case XIE_OFF_ROW: case XIE_OFF_ROW:
if (_row_dirty && _check_enabled) if (_row_dirty && _check_enabled)
{ {
_check_enabled = FALSE; // Avoid recursion! _check_enabled = FALSE; // Avoid recursion!
str2mask(_cur_rec); // It shouldn't have to be necessary str2mask(_cur_rec); // It shouldn't have to be necessary
bool ok = sheet_mask().check_fields(); bool ok = sheet_mask().check_fields();
@ -624,20 +641,16 @@ break;
ok = notify(_cur_rec, K_ENTER); // Notify edit ok = notify(_cur_rec, K_ENTER); // Notify edit
} }
if (!ok) if (!ok)
{
xiev->refused = TRUE; xiev->refused = TRUE;
}
else else
{
set_dirty();
xvt_statbar_refresh(); xvt_statbar_refresh();
}
_check_enabled = TRUE; _check_enabled = TRUE;
} }
break; break;
case XIE_ON_CELL: case XIE_ON_CELL:
if (_check_enabled) if (_check_enabled)
{ {
TMask_field* f = cell2field(xiev->v.xi_obj); TMask_field* f = cell2field(xiev->v.xi_obj);
const int col = (f->dlg()-FIRST_FIELD) % 100; const int col = (f->dlg()-FIRST_FIELD) % 100;
if (cell_disabled(_cur_rec, col)) // If the cell is disabled ... if (cell_disabled(_cur_rec, col)) // If the cell is disabled ...
@ -650,11 +663,11 @@ break;
_cur_col = xiev->v.xi_obj->v.cell.column; _cur_col = xiev->v.xi_obj->v.cell.column;
_cell_dirty = FALSE; _cell_dirty = FALSE;
} }
} }
break; break;
case XIE_OFF_CELL: case XIE_OFF_CELL:
if (_edit_field && _check_enabled) if (_edit_field && _check_enabled)
{ {
_check_enabled = FALSE; _check_enabled = FALSE;
if (_cell_dirty) if (_cell_dirty)
{ {
@ -673,19 +686,19 @@ break;
} }
} }
_check_enabled = TRUE; _check_enabled = TRUE;
} }
break; break;
case XIE_GET_PERCENT: case XIE_GET_PERCENT:
{ {
const long rec = xiev->v.get_percent.record; const long rec = xiev->v.get_percent.record;
long n = items(); if (n < 1) n = 1; long n = items(); if (n < 1) n = 1;
xiev->v.get_percent.percent = int(rec * 100L / n); xiev->v.get_percent.percent = int(rec * 100L / n);
} }
break; break;
case XIE_CLEANUP: case XIE_CLEANUP:
break; break;
case XIE_XVT_EVENT: case XIE_XVT_EVENT:
{ {
EVENT* ep = &xiev->v.xvte; EVENT* ep = &xiev->v.xvte;
switch (ep->type) switch (ep->type)
{ {
@ -749,12 +762,14 @@ break;
break; break;
case K_PREV: case K_PREV:
case K_NEXT: case K_NEXT:
case K_ESC:
if (xi_move_focus(_itf)) if (xi_move_focus(_itf))
dispatch_e_char(parent(), k); dispatch_e_char(parent(), k);
break; break;
case K_ESC: case K_ENTER:
xi_set_focus(_itf); case K_SHIFT+K_ENTER:
dispatch_e_char(parent(), K_ESC); if (xi_move_focus(_itf))
dispatch_e_char(parent(), k == K_ENTER ? K_TAB : K_BTAB);
break; break;
case K_CTRL+K_PREV: case K_CTRL+K_PREV:
xi_scroll(_list, XI_SCROLL_PGUP); xi_scroll(_list, XI_SCROLL_PGUP);
@ -776,11 +791,11 @@ break;
default: default:
break; break;
} }
} }
break; break;
default: default:
break; break;
} }
} }
void TSpreadsheet::activate(bool on) void TSpreadsheet::activate(bool on)
@ -855,6 +870,7 @@ public:
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; } void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork);} void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork);}
bool dirty() const { return _owner->dirty(); } bool dirty() const { return _owner->dirty(); }
bool test_focus_change() { return TRUE; }
void mask2str(int riga); void mask2str(int riga);
void str2mask(int riga); void str2mask(int riga);
@ -1263,14 +1279,13 @@ void TSheet_field::set_notify(SPREADSHEET_NOTIFY n)
void TSheet_field::highlight() const void TSheet_field::highlight() const
{ {
TMask_field::highlight();
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
if (_sheet->_firstfocus && items()) if (items())
{ {
_sheet->_firstfocus = FALSE; _sheet->_firstfocus = FALSE;
_sheet->set_focus_cell(0, 1); _sheet->set_focus_cell(0, 1);
} }
#else
TMask_field::highlight();
#endif #endif
} }
@ -1311,20 +1326,18 @@ bool TSheet_field::on_hit()
return TRUE; return TRUE;
} }
bool TSheet_field::test_focus_change()
{
return _sheet->test_focus_change();
}
bool TSheet_field::on_key(KEY k) bool TSheet_field::on_key(KEY k)
{ {
if (k == K_TAB || k == K_ENTER) if (k == K_ENTER)
{ {
if (dirty() > TRUE) if (!test_focus_change())
return FALSE; return FALSE;
if (k == K_ENTER && dirty())
{
_sheet->str2mask(selected());
const bool ok = sheet_mask().check_fields();
if (!ok) return FALSE;
} }
}
return TMask_field::on_key(k); return TMask_field::on_key(k);
} }

View File

@ -19,6 +19,7 @@ protected:
virtual word class_id() const; virtual word class_id() const;
virtual bool on_hit(); virtual bool on_hit();
virtual bool on_key(KEY k); virtual bool on_key(KEY k);
virtual bool test_focus_change();
virtual void parse_head(TScanner& scanner); virtual void parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.44 1995-01-04 15:39:31 guy Exp $ // $Id: relapp.cpp,v 1.45 1995-01-16 15:10:45 guy Exp $
#include <mailbox.h> #include <mailbox.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -623,6 +623,7 @@ bool TRelation_application::save(bool check_dirty)
} }
was_dirty = FALSE; was_dirty = FALSE;
begin_wait();
if (mode == MODE_INS) if (mode == MODE_INS)
{ {
bool changed = TRUE; bool changed = TRUE;
@ -648,6 +649,7 @@ bool TRelation_application::save(bool check_dirty)
get_relation()->restore_status(); get_relation()->restore_status();
err = rewrite(*_mask); err = rewrite(*_mask);
} }
end_wait();
switch(err) switch(err)
{ {
@ -743,10 +745,6 @@ bool TRelation_application::main_loop()
k = _mask->run(); k = _mask->run();
// Seleziona il cursore a clessidra se necessario
if (k != K_QUIT && k != K_F9)
begin_wait();
switch (k) switch (k)
{ {
case K_ESC: case K_ESC:
@ -830,9 +828,6 @@ bool TRelation_application::main_loop()
} }
break; break;
} }
if (k != K_QUIT && k != K_F9)
end_wait();
} while (k != K_QUIT); } while (k != K_QUIT);
if (_mask->is_open()) if (_mask->is_open())

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.30 1995-01-09 16:51:18 guy Exp $ // $Id: relation.cpp,v 1.31 1995-01-16 15:10:49 guy Exp $
// relation.cpp // relation.cpp
// fv 12/8/93 // fv 12/8/93
// relation class for isam files // relation class for isam files
@ -1104,9 +1104,11 @@ TRecnotype TCursor::readrec()
FILE* _f = open_index(); FILE* _f = open_index();
if ((fseek(_f, _pos * sizeof(TRecnotype), SEEK_SET) != 0) || if (fseek(_f, _pos * sizeof(TRecnotype), SEEK_SET) != 0)
(fread(&nrec, sizeof(TRecnotype), 1, _f) != 1)) fatal_box("Can't seek position %ld in cursor n. %d\n", _pos, file().filehnd()->ln);
fatal_box("Can't read record in file n. %d\n", file().filehnd()->ln);
if (fread(&nrec, sizeof(TRecnotype), 1, _f) != 1)
fatal_box("Can't read position %ld in cursor n. %d\n", _pos, file().filehnd()->ln);
fclose(_f); fclose(_f);

View File

@ -24,6 +24,9 @@ HIDDEN const int MAXSTR = 301;
HIDDEN char __spark[MAXSTR]; // Utility buffer HIDDEN char __spark[MAXSTR]; // Utility buffer
TFixed_string spark(__spark, MAXSTR); TFixed_string spark(__spark, MAXSTR);
inline bool is_space(char c)
{ return c >= K_TAB && c <= K_SPACE; }
// Dinamically resizes a string // Dinamically resizes a string
// Certified 99% // Certified 99%
// It doesn't work for static strings and negative values of size // It doesn't work for static strings and negative values of size
@ -156,7 +159,7 @@ TString& TString::strip_spaces()
for (int i = 0; _str[i]; i++) for (int i = 0; _str[i]; i++)
{ {
char c = _str[i]; char c = _str[i];
if (isspace(c) && !instring) continue; if (is_space(c) && !instring) continue;
if (c == '"' || c == '\'') if (c == '"' || c == '\'')
{ {
if (instring == c) instring = '\0'; if (instring == c) instring = '\0';
@ -301,7 +304,7 @@ TString& TString::ltrim(int count)
if (count >= len()) return cut(0); if (count >= len()) return cut(0);
s = &_str[count]; s = &_str[count];
} }
else for (s = _str; *s && isspace(*s); s++); else for (s = _str; *s && is_space(*s); s++);
if (s != _str) strcpy(_str, s); if (s != _str) strcpy(_str, s);
return *this; return *this;
@ -318,7 +321,8 @@ TString& TString::rtrim(int count)
else else
{ {
char* good = _str-1; char* good = _str-1;
for (char* s = _str; *s; s++) if (!isspace(*s)) good = s; for (char* s = _str; *s; s++)
if (!is_space(*s)) good = s;
*(good+1) = '\0'; *(good+1) = '\0';
} }
return *this; return *this;
@ -329,7 +333,7 @@ TString& TString::trim()
char* last = _str; char* last = _str;
// Salta spazi iniziali // Salta spazi iniziali
for (const char* s = _str; *s && isspace(*s); s++); for (const char* s = _str; *s && is_space(*s); s++);
// Copia stringa // Copia stringa
if (s > _str) if (s > _str)
@ -337,7 +341,7 @@ TString& TString::trim()
for(char* c = _str; *s; s++) for(char* c = _str; *s; s++)
{ {
*c++ = *s; *c++ = *s;
if (!isspace(*s)) last = c; if (!is_space(*s)) last = c;
} }
// Elimina spazi finali // Elimina spazi finali
*last = '\0'; *last = '\0';
@ -896,7 +900,7 @@ int TToken_string::get_pos(const char* s)
bool TToken_string::empty_items() const bool TToken_string::empty_items() const
{ {
for (const char* c = _str; *c; c++) for (const char* c = _str; *c; c++)
if (!isspace(*c) && *c != _separator) return FALSE; if (!is_space(*c) && *c != _separator) return FALSE;
return TRUE; return TRUE;
} }
@ -999,7 +1003,7 @@ void TParagraph_string::tokenize()
for (int end = start+_width; end < len(); end = start+_width) for (int end = start+_width; end < len(); end = start+_width)
{ {
for (int i = end; i >= start; i--) for (int i = end; i >= start; i--)
if (isspace(_str[i])) break; if (is_space(_str[i])) break;
if (i < start) if (i < start)
{ {