assoc.cpp Da' errore se si cerca un oggetto inesistente

form.cpp    Aggiunte le righe smussate
form.h      Aggiunto metodo set_prompt
printer.cpp Aggiunte righe smussate


git-svn-id: svn://10.65.10.50/trunk@2304 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-12-15 17:11:18 +00:00
parent 96d8ac438d
commit c3911bba9e
4 changed files with 62 additions and 17 deletions

View File

@ -194,14 +194,19 @@ TObject& TAssoc_array::find(
// @comm Cerca l'oggetto indicizzato con chiave <p key>. Viene controllato se // @comm Cerca l'oggetto indicizzato con chiave <p key>. Viene controllato se
// non c'e' (normalmente si usa operator[key]) // non c'e' (normalmente si usa operator[key])
// //
// @rdesc Ritorna l'oggetto cercato. Se l'oggetto aggiunto era NULL // @rdesc Ritorna l'oggetto cercato. Se l'oggetto non viene trovato
// ritorna error object // ritorna un errore
{ {
/* Guy ruined this
bool isnew = FALSE; bool isnew = FALSE;
THash_object* o = _lookup(key, isnew); THash_object* o = _lookup(key, isnew);
if (o == NULL) error_box("INTERNAL (HASH): Unref key"); if (o == NULL) error_box("INTERNAL (HASH): Unref key");
if (o->_obj == NULL) return error; if (o->_obj == NULL) return error;
else return *(o->_obj); else return *(o->_obj);
*/
TObject* o = objptr(key);
CHECKS(o, "Can't find hash object with key ", key);
return *o;
} }
// @mfunc Ritorna l'oggetto con chiave <p key> // @mfunc Ritorna l'oggetto con chiave <p key>
@ -210,10 +215,10 @@ TObject* TAssoc_array::objptr(
// @rdesc Se l'oggetto esiste ne ritorna il puntatore, altrimenti ritorna NULL // @rdesc Se l'oggetto esiste ne ritorna il puntatore, altrimenti ritorna NULL
{ {
bool isnew; bool isnew = FALSE;
THash_object* o = NULL; THash_object* o = _lookup(key,isnew);
if ((o = _lookup(key,isnew)) != NULL) if (o != NULL)
return &(o->obj()); return o->_obj;
return NULL; return NULL;
} }

View File

@ -1770,9 +1770,26 @@ bool TForm_picture::update()
bool TForm_line::update() bool TForm_line::update()
{ {
int spessore = 1;
char codice = 'l';
for (int j = _prompt.len()-1; j >= 0; j--)
{
switch (_prompt[j])
{
case 'B':
case 'b':
spessore = 3; break;
case 'R':
case 'r':
codice = 'r'; break;
default:
break;
}
}
TString80 i; TString80 i;
const int w = _prompt[0] == '@' ? 3 : 1; i << 'W' << spessore << codice
i << 'W' << w << "l{" << _x << ',' << _y << ',' << '{' << _x << ',' << _y << ','
<< (_x+width()-1) << ',' << (_y+height()-1) << '}'; << (_x+width()-1) << ',' << (_y+height()-1) << '}';
((TGraphic_section&)section()).append(i); ((TGraphic_section&)section()).append(i);
@ -1791,7 +1808,6 @@ bool TForm_box::update()
} }
TForm_item* TGraphic_section::parse_item(const TString& s) TForm_item* TGraphic_section::parse_item(const TString& s)
{ {
if (s == "FI") if (s == "FI")

View File

@ -324,6 +324,8 @@ protected:
void string_at(int x, int y, const char* s); void string_at(int x, int y, const char* s);
const char* get_special_item(const char* s, int n) const;
public: public:
short id() const { return _id; } short id() const { return _id; }
@ -366,8 +368,8 @@ public:
// example() ritorna un esempio del formato corrente // example() ritorna un esempio del formato corrente
virtual const char* example() const { return ""; } virtual const char* example() const { return ""; }
// const char* prompt() const { return _prompt; }
const TString& prompt() const { return _prompt; } const TString& prompt() const { return _prompt; }
void set_prompt(const char* s) { _prompt = s; }
virtual const TString& picture() const; // Da' CHECK virtual const TString& picture() const; // Da' CHECK
virtual void set_picture(const char*); // Da' CHECK virtual void set_picture(const char*); // Da' CHECK
@ -391,11 +393,12 @@ public:
// variabili personalizzate low-level // variabili personalizzate low-level
int special_items() const { return _special.items(); } int special_items() const { return _special.items(); }
TAssoc_array& specials() const { return (TAssoc_array&)_special; } TAssoc_array& specials() const { return (TAssoc_array&)_special; }
// high-level // high-level
int get_special_names(TString_array& r); int get_special_names(TString_array& r);
const char* get_special_value(const char*); const char* get_special_value(const char* s) const { return get_special_item(s, 1); }
const char* get_special_type (const char*); const char* get_special_type (const char* s) const { return get_special_item(s, 0); }
const char* get_special_description(const char*); const char* get_special_desc (const char* s) const { return get_special_item(s, 2); }
TForm_item(TPrint_section* section); TForm_item(TPrint_section* section);
virtual ~TForm_item() {} virtual ~TForm_item() {}

View File

@ -232,7 +232,7 @@ void TPrinter::parse_background(const char* bg_desc, TArray& background)
// la stringa contiene l'opcode piu' i parametri in binario, // la stringa contiene l'opcode piu' i parametri in binario,
// incrementati di 1 per evitare lo 0 // incrementati di 1 per evitare lo 0
switch (*(tt.get(0))) switch (tt.get_char(0))
{ {
case 'b': case 'b':
x1 = tt.get_int (1) + 1; x1 = tt.get_int (1) + 1;
@ -263,7 +263,6 @@ void TPrinter::parse_background(const char* bg_desc, TArray& background)
x2 = tt.get_int (3) + 1; x2 = tt.get_int (3) + 1;
y2 = tt.get_int (4) + 1; y2 = tt.get_int (4) + 1;
if (y1 == y2 && y1 == l + 1) // orizzontale if (y1 == y2 && y1 == l + 1) // orizzontale
{ {
rwd << 'h' << char (x1) << char (x2); rwd << 'h' << char (x1) << char (x2);
} }
@ -273,6 +272,28 @@ void TPrinter::parse_background(const char* bg_desc, TArray& background)
rwd << 'v' << char (x1); rwd << 'v' << char (x1);
} }
break; break;
case 'r':
x1 = tt.get_int (1) + 1;
y1 = tt.get_int (2) + 1;
x2 = tt.get_int (3) + 1;
y2 = tt.get_int (4) + 1;
if (y1 == y2) // orizzontale
{
if (y1 == l+1)
rwd << 'r' << char (x1) << char (x2);
}
else
{
const int l1 = l+1;
if (l1 >= y1 && l1 <= y2) // verticale
{
char code = 'v';
if (y1 == l1) code = 'u'; else
if (y2 == l1) code = 'o';
rwd << code << char(x1);
}
}
break;
case 't': case 't':
x1 = tt.get_int (1) + 1; x1 = tt.get_int (1) + 1;
y1 = tt.get_int (2) + 1; // al gh'e' y1 = tt.get_int (2) + 1; // al gh'e'