Преглед на файлове

[bugfix][Fix #35] redraw border win on SIGWINCH

B Thibault преди 9 години
родител
ревизия
c845896f6e
променени са 4 файла, в които са добавени 29 реда и са изтрити 1 реда
  1. 5 0
      include/curseOutput.hh
  2. 2 0
      include/curseSplitOutput.hh
  3. 6 1
      src/curseOutput.cpp
  4. 16 0
      src/curseSplitOutput.cpp

+ 5 - 0
include/curseOutput.hh

@@ -60,6 +60,11 @@ class CurseOutput
         **/
         virtual void shutdown() =0;
 
+        /**
+         * Called before redraw after window got SIGWINCH'd
+        **/
+        virtual void onResizeHandler(const t_Cursor &);
+
         /**
          * return false if bottom of screen is touched
          * redraw all data

+ 2 - 0
include/curseSplitOutput.hh

@@ -90,6 +90,8 @@ class CurseSplitOutput: public CurseOutput
         inputResult nextResult();
         inputResult changeWindow(char, bool);
 
+        void onResizeHandler(const t_Cursor &);
+
         void setSelection(const JSonElement *);
 
         void computeDiff();

+ 6 - 1
src/curseOutput.cpp

@@ -44,6 +44,11 @@ void CurseOutput::loop(WINDOW * w)
     } while (read != inputResult::quit);
 }
 
+void CurseOutput::onResizeHandler(const t_Cursor &)
+{
+    clear();
+}
+
 bool CurseOutput::onsig(int signo)
 {
     struct winsize size;
@@ -53,7 +58,7 @@ bool CurseOutput::onsig(int signo)
     case SIGWINCH:
         if (ioctl(fileno(screen_fd ? screen_fd : stdout), TIOCGWINSZ, &size) == 0)
             resize_term(size.ws_row, size.ws_col);
-        clear();
+        onResizeHandler(getScreenSize());
         while (!redraw());
         break;
 

+ 16 - 0
src/curseSplitOutput.cpp

@@ -414,6 +414,22 @@ const Optional<bool> CurseSplitOutput::redrawOneItemToWorkingWin(t_subWindow &w,
     return Optional<bool>::of(false);
 }
 
+void CurseSplitOutput::onResizeHandler(const t_Cursor &screenSize)
+{
+    size_t i =0;
+    destroyAllSubWin();
+    clear();
+
+    for (t_subWindow &subwin: subWindows)
+    {
+        subwin.outerWin = newwin(screenSize.second +2, screenSize.first, 0, i * (screenSize.first -1));
+        subwin.innerWin = newwin(screenSize.second, screenSize.first -2, 1, i * (screenSize.first -1) +1);
+        box(subwin.outerWin, 0, 0);
+        wrefresh(subwin.outerWin);
+        ++i;
+    }
+}
+
 bool CurseSplitOutput::redraw()
 {
     const t_Cursor screenSize = getScreenSize();