From c3911bba9e40c02124d04ef21c114da71cd461a9 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 15 Dec 1995 17:11:18 +0000 Subject: [PATCH] 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 --- include/assoc.cpp | 17 +++++++++++------ include/form.cpp | 24 ++++++++++++++++++++---- include/form.h | 13 ++++++++----- include/printer.cpp | 25 +++++++++++++++++++++++-- 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/include/assoc.cpp b/include/assoc.cpp index 4674b0b32..cc282eeed 100755 --- a/include/assoc.cpp +++ b/include/assoc.cpp @@ -194,14 +194,19 @@ TObject& TAssoc_array::find( // @comm Cerca l'oggetto indicizzato con chiave

. Viene controllato se // non c'e' (normalmente si usa operator[key]) // - // @rdesc Ritorna l'oggetto cercato. Se l'oggetto aggiunto era NULL - // ritorna error object + // @rdesc Ritorna l'oggetto cercato. Se l'oggetto non viene trovato + // ritorna un errore { +/* Guy ruined this bool isnew = FALSE; THash_object* o = _lookup(key, isnew); if (o == NULL) error_box("INTERNAL (HASH): Unref key"); if (o->_obj == NULL) return error; 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

@@ -210,10 +215,10 @@ TObject* TAssoc_array::objptr( // @rdesc Se l'oggetto esiste ne ritorna il puntatore, altrimenti ritorna NULL { - bool isnew; - THash_object* o = NULL; - if ((o = _lookup(key,isnew)) != NULL) - return &(o->obj()); + bool isnew = FALSE; + THash_object* o = _lookup(key,isnew); + if (o != NULL) + return o->_obj; return NULL; } diff --git a/include/form.cpp b/include/form.cpp index 9e3d79a20..4447d8321 100755 --- a/include/form.cpp +++ b/include/form.cpp @@ -1770,9 +1770,26 @@ bool TForm_picture::update() bool TForm_line::update() { - TString80 i; - const int w = _prompt[0] == '@' ? 3 : 1; - i << 'W' << w << "l{" << _x << ',' << _y << ',' + 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; + i << 'W' << spessore << codice + << '{' << _x << ',' << _y << ',' << (_x+width()-1) << ',' << (_y+height()-1) << '}'; ((TGraphic_section&)section()).append(i); @@ -1791,7 +1808,6 @@ bool TForm_box::update() } - TForm_item* TGraphic_section::parse_item(const TString& s) { if (s == "FI") diff --git a/include/form.h b/include/form.h index fd2db3322..aac5fd807 100755 --- a/include/form.h +++ b/include/form.h @@ -323,7 +323,9 @@ protected: bool do_message(int m = 0); void string_at(int x, int y, const char* s); - + + const char* get_special_item(const char* s, int n) const; + public: short id() const { return _id; } @@ -366,8 +368,8 @@ public: // example() ritorna un esempio del formato corrente virtual const char* example() const { return ""; } -// const char* 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 void set_picture(const char*); // Da' CHECK @@ -391,11 +393,12 @@ public: // variabili personalizzate low-level int special_items() const { return _special.items(); } TAssoc_array& specials() const { return (TAssoc_array&)_special; } + // high-level int get_special_names(TString_array& r); - const char* get_special_value(const char*); - const char* get_special_type (const char*); - const char* get_special_description(const char*); + const char* get_special_value(const char* s) const { return get_special_item(s, 1); } + const char* get_special_type (const char* s) const { return get_special_item(s, 0); } + const char* get_special_desc (const char* s) const { return get_special_item(s, 2); } TForm_item(TPrint_section* section); virtual ~TForm_item() {} diff --git a/include/printer.cpp b/include/printer.cpp index ceb0995e4..4abc830e0 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -232,7 +232,7 @@ void TPrinter::parse_background(const char* bg_desc, TArray& background) // la stringa contiene l'opcode piu' i parametri in binario, // incrementati di 1 per evitare lo 0 - switch (*(tt.get(0))) + switch (tt.get_char(0)) { case 'b': 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; y2 = tt.get_int (4) + 1; if (y1 == y2 && y1 == l + 1) // orizzontale - { rwd << 'h' << char (x1) << char (x2); } @@ -273,6 +272,28 @@ void TPrinter::parse_background(const char* bg_desc, TArray& background) rwd << 'v' << char (x1); } 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': x1 = tt.get_int (1) + 1; y1 = tt.get_int (2) + 1; // al gh'e'