From 13509ef9662c0638fe3297b3622e801e2989b5c1 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 10 Apr 2014 12:51:42 +0000
Subject: [PATCH] refresh options/workspace window automatically

---
 Common/CommandLine.cpp |  1 +
 Fltk/FlGui.cpp         |  2 ++
 Fltk/helpWindow.cpp    | 15 +++++++++------
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index 1d3fece474..028c7fcd40 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -185,6 +185,7 @@ std::vector<std::pair<std::string, std::string> > GetShortcutsUsage(const std::s
   s.push_back(mp(cc + "r",         "Rename project file"));
   s.push_back(mp(cc + "s",         "Save file as"));
   s.push_back(mp("Shift+" + cc + "c", "Show clipping plane window"));
+  s.push_back(mp("Shift+" + cc + "h", "Show current options and workspace window"));
   s.push_back(mp("Shift+" + cc + "j", "Save options as default"));
   s.push_back(mp("Shift+" + cc + "m", "Show manipulator window"));
   s.push_back(mp("Shift+" + cc + "n", "Show option window"));
diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp
index cb3a1df398..7b7cdab727 100644
--- a/Fltk/FlGui.cpp
+++ b/Fltk/FlGui.cpp
@@ -779,6 +779,8 @@ void FlGui::resetVisibility()
 {
   if(visibility->win->shown())
     visibility_cb(NULL, NULL);
+  if(help->options->shown())
+    help_options_cb(NULL, NULL);
 }
 
 openglWindow *FlGui::getCurrentOpenglWindow()
diff --git a/Fltk/helpWindow.cpp b/Fltk/helpWindow.cpp
index 3031399ab4..ad11817667 100644
--- a/Fltk/helpWindow.cpp
+++ b/Fltk/helpWindow.cpp
@@ -245,26 +245,29 @@ void help_options_cb(Fl_Widget *w, void *data)
 
   PrintOptions(0, GMSH_FULLRC, diff, help, 0, &s0);
   PrintParserSymbols(help, s0);
+
+  int top = FlGui::instance()->help->browser->topline();
   FlGui::instance()->help->browser->clear();
   for(unsigned int i = 0; i < s0.size(); i++){
     std::string::size_type sep = s0[i].rfind('\0');
-    void *data = 0;
+    void *d = 0;
     if(sep != std::string::npos){
       std::string tmp = s0[i].substr(sep + 1);
-      if(tmp == "number") data = (void*)"number";
-      else if(tmp == "string") data = (void*)"string";
-      else if(tmp == "color") data = (void*)"color";
+      if(tmp == "number") d = (void*)"number";
+      else if(tmp == "string") d = (void*)"string";
+      else if(tmp == "color") d = (void*)"color";
     }
     if(search.empty()){
-      FlGui::instance()->help->browser->add(s0[i].c_str(), data);
+      FlGui::instance()->help->browser->add(s0[i].c_str(), d);
     }
     else{
       std::string tmp(s0[i]);
       std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
       if(tmp.find(search) != std::string::npos)
-        FlGui::instance()->help->browser->add(s0[i].c_str(), data);
+        FlGui::instance()->help->browser->add(s0[i].c_str(), d);
     }
   }
+  FlGui::instance()->help->browser->topline(top);
 }
 
 helpWindow::helpWindow()
-- 
GitLab