From: <ssh...@us...> - 2012-01-21 20:36:39
|
Revision: 10998 http://bochs.svn.sourceforge.net/bochs/?rev=10998&view=rev Author: sshwarts Date: 2012-01-21 20:36:32 +0000 (Sat, 21 Jan 2012) Log Message: ----------- for bx_list param - convert 'choise' variable to regular integer also for textconfig - fix operation under cygwin under cygwin it is not guaranteed that any printf is printed on the screen under you flush the FILE stream. Modified Paths: -------------- trunk/bochs/gui/paramtree.cc trunk/bochs/gui/paramtree.h trunk/bochs/gui/textconfig.cc Modified: trunk/bochs/gui/paramtree.cc =================================================================== --- trunk/bochs/gui/paramtree.cc 2012-01-21 12:15:10 UTC (rev 10997) +++ trunk/bochs/gui/paramtree.cc 2012-01-21 20:36:32 UTC (rev 10998) @@ -934,7 +934,6 @@ delete [] list; } if (title != NULL) delete [] title; - if (choice != NULL) delete choice; } void bx_list_c::init(const char *list_title) @@ -947,8 +946,7 @@ this->title[0] = 0; } this->options = 0; - this->choice = new bx_param_num_c(NULL, - "list_choice", "", "", 0, BX_MAX_BIT64S, 1); + this->choice = 1; } void bx_list_c::set_parent(bx_param_c *newparent) Modified: trunk/bochs/gui/paramtree.h =================================================================== --- trunk/bochs/gui/paramtree.h 2012-01-21 12:15:10 UTC (rev 10997) +++ trunk/bochs/gui/paramtree.h 2012-01-21 20:36:32 UTC (rev 10998) @@ -439,9 +439,9 @@ bx_param_c **list; int size, maxsize; // for a menu, the value of choice before the call to "ask" is default. - // After ask, choice holds the value that the user chose. Choice defaults + // After ask, choice holds the value that the user chose. Choice defaults // to 1 in the constructor. - bx_param_num_c *choice; + int choice; // title of the menu or series char *title; void init(const char *list_title); @@ -478,7 +478,8 @@ bx_param_c *get(int index); bx_param_c *get_by_name(const char *name); int get_size() const { return size; } - bx_param_num_c *get_choice() { return choice; } + int get_choice() const { return choice; } + void set_choice(int new_choice) { choice = new_choice; } char *get_title() { return title; } void set_parent(bx_param_c *newparent); bx_param_c *get_parent() { return parent; } Modified: trunk/bochs/gui/textconfig.cc =================================================================== --- trunk/bochs/gui/textconfig.cc 2012-01-21 12:15:10 UTC (rev 10997) +++ trunk/bochs/gui/textconfig.cc 2012-01-21 20:36:32 UTC (rev 10998) @@ -95,6 +95,7 @@ assert(base==10 || base==16); while (1) { printf(prompt, the_default); + fflush(stdout); if (!fgets(buffer, sizeof(buffer), stdin)) return -1; clean = clean_string(buffer); @@ -139,6 +140,7 @@ int illegal; while (1) { printf(prompt, the_default); + fflush(stdout); if (!fgets(buffer, sizeof(buffer), stdin)) return -1; clean = clean_string(buffer); @@ -172,6 +174,7 @@ *out = -1; while (1) { printf(prompt, choice[the_default]); + fflush(stdout); if (!fgets(buffer, sizeof(buffer), stdin)) return -1; clean = clean_string(buffer); @@ -208,6 +211,7 @@ while (1) { // if there's a %s field, substitute in the default yes/no. printf(prompt, the_default ? "yes" : "no"); + fflush(stdout); if (!fgets(buffer, sizeof(buffer), stdin)) return -1; clean = clean_string(buffer); @@ -240,6 +244,7 @@ assert(the_default != out); out[0] = 0; printf(prompt, the_default); + fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) return -1; clean = clean_string(buffer); @@ -372,14 +377,13 @@ { bx_list_c *menu = (bx_list_c *)SIM->get_param(pname, NULL); while (1) { - menu->get_choice()->set(0); + menu->set_choice(0); int status = menu->text_ask(stdin, stderr); if (status < 0) return status; - bx_param_num_c *choice = menu->get_choice(); - if (choice->get() < 1) - return choice->get(); + if (menu->get_choice() < 1) + return menu->get_choice(); else { - int index = choice->get() - 1; // choosing 1 means list[0] + int index = menu->get_choice() - 1; // choosing 1 means list[0] bx_param_c *chosen = menu->get(index); assert(chosen != NULL); if (chosen->get_enabled()) { @@ -995,12 +999,11 @@ } } fprintf(fpout, "\n"); - Bit32u n = choice->get(); + Bit32u n = (Bit32u) choice; int min = (options & SHOW_PARENT) ? 0 : 1; int max = size; int status = ask_uint("Please choose one: [%d] ", "", min, max, n, &n, 10); if (status < 0) return status; - choice->set(n); } return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |