STR 3460: shell window remembers position

The Fluid window to display the execute shell command result
is now reopened where it was previously closed.
This commit is contained in:
Matthias Melcher 2019-01-14 00:09:31 +01:00
parent 3d6b234c27
commit b71601fe7c
4 changed files with 55 additions and 36 deletions

View File

@ -22,7 +22,6 @@
#include <FL/Fl_Preferences.H> #include <FL/Fl_Preferences.H>
#include <FL/fl_ask.H> #include <FL/fl_ask.H>
#include <string.h> #include <string.h>
Fl_Text_Buffer *shell_run_buffer;
Fl_Double_Window *project_window=(Fl_Double_Window *)0; Fl_Double_Window *project_window=(Fl_Double_Window *)0;
@ -357,12 +356,17 @@ static void cb_Cancel(Fl_Button*, void*) {
Fl_Double_Window *shell_run_window=(Fl_Double_Window *)0; Fl_Double_Window *shell_run_window=(Fl_Double_Window *)0;
Fl_Text_Display *shell_run_display=(Fl_Text_Display *)0; Fl_Simple_Terminal *shell_run_terminal=(Fl_Simple_Terminal *)0;
Fl_Return_Button *shell_run_button=(Fl_Return_Button *)0; Fl_Return_Button *shell_run_button=(Fl_Return_Button *)0;
static void cb_shell_run_button(Fl_Return_Button*, void*) { static void cb_shell_run_button(Fl_Return_Button*, void*) {
shell_run_window->hide(); Fl_Preferences pos(fluid_prefs, "shell_run_Window_pos");
pos.set("x", shell_run_window->x());
pos.set("y", shell_run_window->y());
pos.set("w", shell_run_window->w());
pos.set("h", shell_run_window->h());
shell_run_window->hide();
} }
Fl_Double_Window* make_shell_window() { Fl_Double_Window* make_shell_window() {
@ -405,13 +409,18 @@ Fl_Double_Window* make_shell_window() {
shell_window->end(); shell_window->end();
} // Fl_Double_Window* shell_window } // Fl_Double_Window* shell_window
{ shell_run_window = new Fl_Double_Window(555, 430, "Shell Command Output"); { shell_run_window = new Fl_Double_Window(555, 430, "Shell Command Output");
{ shell_run_display = new Fl_Text_Display(10, 10, 535, 375); { shell_run_terminal = new Fl_Simple_Terminal(10, 10, 535, 375);
shell_run_display->box(FL_DOWN_BOX); shell_run_terminal->box(FL_DOWN_BOX);
shell_run_display->textfont(4); shell_run_terminal->color(FL_FOREGROUND_COLOR);
Fl_Group::current()->resizable(shell_run_display); shell_run_terminal->selection_color(FL_BACKGROUND_COLOR);
shell_run_buffer = new Fl_Text_Buffer(); shell_run_terminal->labeltype(FL_NORMAL_LABEL);
shell_run_display->buffer(shell_run_buffer); shell_run_terminal->labelfont(0);
} // Fl_Text_Display* shell_run_display shell_run_terminal->labelsize(14);
shell_run_terminal->labelcolor(FL_FOREGROUND_COLOR);
shell_run_terminal->align(Fl_Align(FL_ALIGN_CENTER));
shell_run_terminal->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(shell_run_terminal);
} // Fl_Simple_Terminal* shell_run_terminal
{ shell_run_button = new Fl_Return_Button(468, 395, 77, 25, "Close"); { shell_run_button = new Fl_Return_Button(468, 395, 77, 25, "Close");
shell_run_button->callback((Fl_Callback*)cb_shell_run_button); shell_run_button->callback((Fl_Callback*)cb_shell_run_button);
} // Fl_Return_Button* shell_run_button } // Fl_Return_Button* shell_run_button

View File

@ -28,6 +28,9 @@ decl {\#include <FL/Fl_Text_Buffer.H>} {public local
decl {\#include <FL/Fl_Text_Display.H>} {public local decl {\#include <FL/Fl_Text_Display.H>} {public local
} }
decl {\#include <FL/Fl_Simple_Terminal.H>} {public local
}
decl {\#include <FL/filename.H>} {public local decl {\#include <FL/filename.H>} {public local
} }
@ -37,7 +40,7 @@ decl {\#include <FL/Fl_Preferences.H>} {private global
decl {\#include <FL/fl_ask.H>} {private global decl {\#include <FL/fl_ask.H>} {private global
} }
decl {\#include <string.h>} {selected private global decl {\#include <string.h>} {private global
} }
decl {extern void load_history();} {public local decl {extern void load_history();} {public local
@ -64,9 +67,6 @@ decl {extern struct Fl_Menu_Item *dbmanager_item;} {public local
decl {extern Fl_Preferences fluid_prefs;} {public local decl {extern Fl_Preferences fluid_prefs;} {public local
} }
decl {Fl_Text_Buffer *shell_run_buffer;} {public local
}
Function {make_project_window()} {open Function {make_project_window()} {open
} { } {
Fl_Window project_window { Fl_Window project_window {
@ -138,7 +138,7 @@ Function {make_project_window()} {open
} }
Fl_Input i18n_include_input { Fl_Input i18n_include_input {
label {\#include:} label {\#include:}
callback i18n_text_cb selected callback i18n_text_cb
tooltip {The include file for internationalization.} xywh {100 78 272 20} box THIN_DOWN_BOX labelfont 1 textfont 4 tooltip {The include file for internationalization.} xywh {100 78 272 20} box THIN_DOWN_BOX labelfont 1 textfont 4
} }
Fl_Input i18n_file_input { Fl_Input i18n_file_input {
@ -281,7 +281,7 @@ redraw_browser();}
callback {strncpy(G_external_editor_command, editor_command_input->value(), sizeof(G_external_editor_command)-1); callback {strncpy(G_external_editor_command, editor_command_input->value(), sizeof(G_external_editor_command)-1);
G_external_editor_command[sizeof(G_external_editor_command)-1] = 0; G_external_editor_command[sizeof(G_external_editor_command)-1] = 0;
fluid_prefs.set("external_editor_command", G_external_editor_command); fluid_prefs.set("external_editor_command", G_external_editor_command);
redraw_browser();} selected redraw_browser();}
tooltip {The editor command to open your external text editor. tooltip {The editor command to open your external text editor.
Include any necessary flags to ensure your editor does not background itself. Include any necessary flags to ensure your editor does not background itself.
Examples: Examples:
@ -300,7 +300,8 @@ Examples:
} }
} }
Function {make_shell_window()} {} { Function {make_shell_window()} {open
} {
Fl_Window shell_window { Fl_Window shell_window {
label {Shell Command} open label {Shell Command} open
xywh {761 190 365 125} type Double hide xywh {761 190 365 125} type Double hide
@ -349,17 +350,21 @@ Function {make_shell_window()} {} {
} }
} }
Fl_Window shell_run_window { Fl_Window shell_run_window {
label {Shell Command Output} label {Shell Command Output} open selected
xywh {592 332 555 430} type Double hide resizable xywh {454 363 555 430} type Double resizable visible
} { } {
Fl_Text_Display shell_run_display { Fl_Box shell_run_terminal {
xywh {10 10 535 375} box DOWN_BOX textfont 4 resizable xywh {10 10 535 375} box DOWN_BOX color 0 resizable
code0 {shell_run_buffer = new Fl_Text_Buffer();} class Fl_Simple_Terminal
code1 {shell_run_display->buffer(shell_run_buffer);}
} }
Fl_Return_Button shell_run_button { Fl_Return_Button shell_run_button {
label Close label Close
callback {shell_run_window->hide();} callback {Fl_Preferences pos(fluid_prefs, "shell_run_Window_pos");
pos.set("x", shell_run_window->x());
pos.set("y", shell_run_window->y());
pos.set("w", shell_run_window->w());
pos.set("h", shell_run_window->h());
shell_run_window->hide();}
xywh {468 395 77 25} xywh {468 395 77 25}
} }
} }

View File

@ -23,6 +23,7 @@
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/Fl_Text_Buffer.H> #include <FL/Fl_Text_Buffer.H>
#include <FL/Fl_Text_Display.H> #include <FL/Fl_Text_Display.H>
#include <FL/Fl_Simple_Terminal.H>
#include <FL/filename.H> #include <FL/filename.H>
extern void load_history(); extern void load_history();
extern void redraw_browser(); extern void redraw_browser();
@ -32,7 +33,6 @@ extern char G_external_editor_command[512];
extern int show_coredevmenus; extern int show_coredevmenus;
extern struct Fl_Menu_Item *dbmanager_item; extern struct Fl_Menu_Item *dbmanager_item;
extern Fl_Preferences fluid_prefs; extern Fl_Preferences fluid_prefs;
extern Fl_Text_Buffer *shell_run_buffer;
#include <FL/Fl_Double_Window.H> #include <FL/Fl_Double_Window.H>
#include <FL/Fl_Preferences.H> #include <FL/Fl_Preferences.H>
#include <FL/Fl_Tooltip.H> #include <FL/Fl_Tooltip.H>
@ -87,8 +87,7 @@ extern Fl_Check_Button *shell_savefl_button;
#include <FL/Fl_Return_Button.H> #include <FL/Fl_Return_Button.H>
extern void do_shell_command(Fl_Return_Button*, void*); extern void do_shell_command(Fl_Return_Button*, void*);
extern Fl_Double_Window *shell_run_window; extern Fl_Double_Window *shell_run_window;
#include <FL/Fl_Text_Display.H> extern Fl_Simple_Terminal *shell_run_terminal;
extern Fl_Text_Display *shell_run_display;
extern Fl_Return_Button *shell_run_button; extern Fl_Return_Button *shell_run_button;
Fl_Double_Window* make_shell_window(); Fl_Double_Window* make_shell_window();
extern Fl_Double_Window *grid_window; extern Fl_Double_Window *grid_window;

View File

@ -1483,16 +1483,13 @@ shell_pipe_cb(FL_SOCKET, void*) {
if (s_proc.get_line(line, sizeof(line)) != NULL) { if (s_proc.get_line(line, sizeof(line)) != NULL) {
// Add the line to the output list... // Add the line to the output list...
shell_run_buffer->append(line); shell_run_terminal->append(line);
} else { } else {
// End of file; tell the parent... // End of file; tell the parent...
Fl::remove_fd(fileno(s_proc.desc())); Fl::remove_fd(fileno(s_proc.desc()));
s_proc.close(); s_proc.close();
shell_run_buffer->append("... END SHELL COMMAND ...\n"); shell_run_terminal->append("... END SHELL COMMAND ...\n");
} }
shell_run_display->scroll(shell_run_display->count_lines(0,
shell_run_buffer->length(), 1), 0);
} }
void void
@ -1502,9 +1499,9 @@ do_shell_command(Fl_Return_Button*, void*) {
if (!prepare_shell_command(command)) return; if (!prepare_shell_command(command)) return;
// Show the output window and clear things... // Show the output window and clear things...
shell_run_buffer->text(""); shell_run_terminal->text("");
shell_run_buffer->append(command); shell_run_terminal->append(command);
shell_run_buffer->append("\n"); shell_run_terminal->append("\n");
shell_run_window->label("Shell Command Running..."); shell_run_window->label("Shell Command Running...");
if (s_proc.popen((char *)command) == NULL) { if (s_proc.popen((char *)command) == NULL) {
@ -1513,7 +1510,16 @@ do_shell_command(Fl_Return_Button*, void*) {
} }
shell_run_button->deactivate(); shell_run_button->deactivate();
shell_run_window->hotspot(shell_run_display);
Fl_Preferences pos(fluid_prefs, "shell_run_Window_pos");
int x, y, w, h;
pos.get("x", x, -1);
pos.get("y", y, 0);
pos.get("w", w, 640);
pos.get("h", h, 480);
if (x!=-1) {
shell_run_window->resize(x, y, w, h);
}
shell_run_window->show(); shell_run_window->show();
Fl::add_fd(fileno(s_proc.desc()), shell_pipe_cb); Fl::add_fd(fileno(s_proc.desc()), shell_pipe_cb);