Commit f270ea9aa907ba1e5f8b2a410d831d6313b60ff3
1 parent
844f2ac2
Exists in
master
and in
5 other branches
Corrigindo montagem dos campos de entrada
Showing
1 changed file
with
27 additions
and
44 deletions
Show diff stats
src/lib3270/html.c
| ... | ... | @@ -101,11 +101,11 @@ |
| 101 | 101 | int szText; |
| 102 | 102 | int form; |
| 103 | 103 | |
| 104 | - enum mode | |
| 104 | + enum HTML_MODE | |
| 105 | 105 | { |
| 106 | - HTML_MODE_TEXT, /**< Non editable */ | |
| 107 | - HTML_MODE_INPUT_TEXT, /**< Text input */ | |
| 108 | - HTML_MODE_INPUT_VALUE, /**< Value input */ | |
| 106 | + HTML_MODE_TEXT, /**< Non editable */ | |
| 107 | + HTML_MODE_INPUT_TEXT, /**< Text input */ | |
| 108 | + HTML_MODE_INPUT_PASSWORD, /**< Password input */ | |
| 109 | 109 | HTML_MODE_INPUT_BUTTON, /**< Button input (PFkey) */ |
| 110 | 110 | } mode; |
| 111 | 111 | |
| ... | ... | @@ -179,7 +179,7 @@ |
| 179 | 179 | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - static void open_input(struct html_info *info, int addr, const char *type) | |
| 182 | + static void open_input(struct html_info *info, int addr, enum HTML_MODE mode) | |
| 183 | 183 | { |
| 184 | 184 | char name[30]; |
| 185 | 185 | |
| ... | ... | @@ -188,21 +188,27 @@ |
| 188 | 188 | snprintf(name,29,"F%04d",addr); |
| 189 | 189 | |
| 190 | 190 | append_string(info,"<input type=\""); |
| 191 | - append_string(info,type); | |
| 191 | + append_string(info,mode == HTML_MODE_INPUT_TEXT ? "text" : "password" ); | |
| 192 | 192 | append_string(info,"\" name=\""); |
| 193 | 193 | append_string(info,name); |
| 194 | - append_string(info,"\""); | |
| 195 | - info->mode = HTML_MODE_INPUT_TEXT; | |
| 194 | + append_string(info,"\" value=\""); | |
| 195 | + info->mode = mode; | |
| 196 | + info->maxlength = 0; | |
| 197 | + | |
| 196 | 198 | } |
| 197 | 199 | |
| 198 | 200 | static void close_input(struct html_info *info) |
| 199 | 201 | { |
| 200 | 202 | char buffer[80]; |
| 203 | + char *ptr; | |
| 201 | 204 | |
| 202 | 205 | if(info->mode == HTML_MODE_TEXT) |
| 203 | 206 | return; |
| 204 | 207 | |
| 205 | - snprintf(buffer,80," maxlength=\"%d\" class=\"IW%03d\"",info->maxlength,info->maxlength); | |
| 208 | + for(ptr = info->text+(strlen(info->text)-1);ptr > info->text && *ptr == ' ';ptr--); | |
| 209 | + *(++ptr) = 0; | |
| 210 | + | |
| 211 | + snprintf(buffer,80,"\" maxlength=\"%d\" class=\"IW%03d\"",info->maxlength,info->maxlength); | |
| 206 | 212 | append_string(info,buffer); |
| 207 | 213 | |
| 208 | 214 | append_string(info,"></input>"); |
| ... | ... | @@ -262,35 +268,9 @@ |
| 262 | 268 | { |
| 263 | 269 | // Input field |
| 264 | 270 | unsigned char attr = get_field_attribute(session,baddr+col+1); |
| 265 | - char * text = lib3270_get_field_at(session,baddr+col+1); | |
| 266 | - | |
| 267 | - open_input(&info,baddr+col+1,FA_IS_ZERO(attr) ? "password" : "text"); | |
| 268 | - | |
| 269 | - if(text) | |
| 270 | - { | |
| 271 | - char *ptr = text; | |
| 272 | - | |
| 273 | - for(ptr = text; *ptr && (*ptr == ' ' || *ptr == '_'); ptr++); | |
| 274 | - | |
| 275 | - if(*ptr) | |
| 276 | - { | |
| 277 | - int f; | |
| 278 | - char * last = ptr; | |
| 279 | - | |
| 280 | - for(f=0;ptr[f];f++) | |
| 281 | - { | |
| 282 | - if(ptr[f] > ' ') | |
| 283 | - last = ptr+f+1; | |
| 284 | - } | |
| 285 | - *last = 0; | |
| 271 | + //char * text = lib3270_get_field_at(session,baddr+col+1); | |
| 286 | 272 | |
| 287 | - append_string(&info," value=\""); | |
| 288 | - append_string(&info,ptr); | |
| 289 | - append_string(&info,"\""); | |
| 290 | - } | |
| 291 | - | |
| 292 | - lib3270_free(text); | |
| 293 | - } | |
| 273 | + open_input(&info,baddr+col+1,FA_IS_ZERO(attr) ? HTML_MODE_INPUT_PASSWORD : HTML_MODE_INPUT_TEXT); | |
| 294 | 274 | |
| 295 | 275 | } |
| 296 | 276 | else if(col < len && session->text[baddr+col+1].chr == 'F') |
| ... | ... | @@ -331,10 +311,11 @@ |
| 331 | 311 | append_string(&info," "); |
| 332 | 312 | } |
| 333 | 313 | } |
| 334 | - else if(info.mode == HTML_MODE_TEXT) | |
| 314 | + else | |
| 335 | 315 | { |
| 336 | 316 | // Normal text |
| 337 | - update_colors(&info,session->text[baddr+col].attr); | |
| 317 | + if(info.mode == HTML_MODE_TEXT) | |
| 318 | + update_colors(&info,session->text[baddr+col].attr); | |
| 338 | 319 | |
| 339 | 320 | if(session->text[baddr+col].attr & LIB3270_ATTR_CG) |
| 340 | 321 | { |
| ... | ... | @@ -363,6 +344,10 @@ |
| 363 | 344 | append_char(&info, xlat, session->text[baddr+col].chr); |
| 364 | 345 | |
| 365 | 346 | } |
| 347 | + else if(session->text[baddr+col].chr == ' ') | |
| 348 | + { | |
| 349 | + append_string(&info,info.mode == HTML_MODE_TEXT ? " " : " "); | |
| 350 | + } | |
| 366 | 351 | else |
| 367 | 352 | { |
| 368 | 353 | static const struct chr_xlat xlat[] = |
| ... | ... | @@ -371,17 +356,15 @@ |
| 371 | 356 | { '&', "&" }, |
| 372 | 357 | { '<', "<" }, |
| 373 | 358 | { '>', ">" }, |
| 374 | - { ' ', " " }, | |
| 375 | 359 | |
| 376 | 360 | { 0x00, NULL } |
| 377 | 361 | }; |
| 362 | + | |
| 378 | 363 | append_char(&info, xlat, session->text[baddr+col].chr); |
| 379 | 364 | } |
| 380 | - } | |
| 381 | - else | |
| 382 | - { | |
| 383 | - // Input contents | |
| 365 | + | |
| 384 | 366 | info.maxlength++; |
| 367 | + | |
| 385 | 368 | } |
| 386 | 369 | } |
| 387 | 370 | } | ... | ... |