Changeset 2316 in MondoRescue for branches/2.2.10/mondo/src/common/newt-specific.c
- Timestamp:
- Aug 18, 2009, 2:34:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/newt-specific.c
r2296 r2316 358 358 log_msg(0, fatalstr); 359 359 log_msg(0, error_string); 360 // popup_and_OK (error_string);361 360 newtFinished(); 362 361 } … … 400 399 finish(int signal) { 401 400 char *command = NULL; 402 403 /* if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */404 405 /* newtPopHelpLine(); */406 401 407 402 chdir("/"); … … 750 745 * @param title The title of the dialog box. 751 746 * @param b The blurb (e.g. what you want the user to enter). 752 * @param output The string to put the user's answer in. 753 * @param maxsize The size in bytes allocated to @p output. 754 * @return TRUE if the user pressed OK, FALSE if they pressed Cancel. 755 */ 756 bool popup_and_get_string(char *title, char *b, char *output, 757 int maxsize) { 747 * @param input The string given originaly as default 748 * @return output string if the user pressed OK, NULL if they pressed Cancel. 749 */ 750 char *popup_and_get_string(char *title, char *b, char *input) { 758 751 759 752 /*@ newt ************************************************************ */ … … 769 762 770 763 /*@ buffers ********************************************************** */ 771 char *blurb; 772 char *original_contents; 773 774 blurb = malloc(MAX_NEWT_COMMENT_LEN); 775 original_contents = malloc(MAX_NEWT_COMMENT_LEN); 764 char *blurb = NULL; 765 char *output = NULL; 766 776 767 assert_string_is_neither_NULL_nor_zerolength(title); 777 768 assert(b != NULL); 778 assert(output != NULL);779 769 780 770 if (g_text_mode) { 781 printf 782 ("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n--> ", 783 title, b); 784 (void) fgets(output, maxsize, stdin); 771 printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q--- [%s]\n--> ", title, b, input); 772 mr_getline(&output, stdin); 773 if (! strcmp(output,"\n")) { 774 /* take default if ENTER was typed */ 775 mr_free(output); 776 mr_asprintf(&output, "%s", input); 777 } 785 778 if (output[strlen(output) - 1] == '\n') 786 779 output[strlen(output) - 1] = '\0'; 787 paranoid_free(blurb); 788 paranoid_free(original_contents); 789 return (TRUE); 790 } 791 strcpy(blurb, b); 780 return (output); 781 } 782 783 mr_asprintf(&blurb, "%s", b); 792 784 text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0); 793 strcpy(original_contents, output);794 output[0] = '\0';795 785 type_here = 796 786 newtEntry(2, newtTextboxGetNumLines(text) + 2, 797 original_contents, 50,787 input, 50, 798 788 #ifdef __cplusplus 799 789 0, NEWT_FLAG_RETURNEXIT … … 804 794 b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, " OK "); 805 795 b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel"); 806 // newtOpenWindow (8, 5, 54, newtTextboxGetNumLines (text) + 9, title);807 796 newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title); 808 797 myForm = newtForm(NULL, NULL, 0); … … 811 800 newtPushHelpLine(blurb); 812 801 b_res = newtRunForm(myForm); 813 strcpy(output, entry_value); 802 803 if (b_res == b_1) { 804 mr_asprintf(&output, "%s", newtEntryGetValue(type_here)); 805 } 814 806 newtPopHelpLine(); 815 807 newtFormDestroy(myForm); 816 808 newtPopWindow(); 817 if (b_res == b_2) { 818 strcpy(output, original_contents); 819 paranoid_free(blurb); 820 paranoid_free(original_contents); 821 return (FALSE); 822 } else { 823 paranoid_free(blurb); 824 paranoid_free(original_contents); 825 return (TRUE); 826 } 809 mr_free(blurb); 810 811 return (output); 827 812 } 828 813 … … 1179 1164 } else { 1180 1165 mr_asprintf(&timeline_str, "%2ld:%02ld taken %2ld:%02ld remaining ", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60); 1181 mr_asprintf( percentline_str, " %3d%% done %3d%% to go", percentage, 100 - percentage);1166 mr_asprintf(&percentline_str, " %3d%% done %3d%% to go", percentage, 100 - percentage); 1182 1167 1183 1168 center_string(blurb1, 54);
Note:
See TracChangeset
for help on using the changeset viewer.