summaryrefslogtreecommitdiff
path: root/src/screen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/screen.cpp')
-rw-r--r--src/screen.cpp130
1 files changed, 85 insertions, 45 deletions
diff --git a/src/screen.cpp b/src/screen.cpp
index 47ffc58d..e5d1565b 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -20,71 +20,61 @@
#include <cassert>
-#include "screen.h"
#include "global.h"
+#include "screen.h"
+#include "settings.h"
using Global::myScreen;
using Global::myLockedScreen;
using Global::myInactiveScreen;
-namespace
+namespace {//
+
+void DrawScreenSeparator(int x)
{
- void DrawScreenSeparator(int x)
- {
- attron(COLOR_PAIR(Config.main_color));
- mvvline(Global::MainStartY, x, 0, Global::MainHeight);
- attroff(COLOR_PAIR(Config.main_color));
- refresh();
- }
+ attron(COLOR_PAIR(Config.main_color));
+ mvvline(Global::MainStartY, x, 0, Global::MainHeight);
+ attroff(COLOR_PAIR(Config.main_color));
+ refresh();
}
-void ApplyToVisibleWindows(void (BasicScreen::*f)())
+}
+
+void GenericMouseButtonPressed(NC::Window *w, MEVENT me)
{
- if (myLockedScreen && myScreen->isMergable())
+ if (me.bstate & BUTTON2_PRESSED)
{
- if (myScreen == myLockedScreen)
- {
- if (myInactiveScreen)
- (myInactiveScreen->*f)();
- }
+ if (Config.mouse_list_scroll_whole_page)
+ w->Scroll(NC::wPageDown);
else
- (myLockedScreen->*f)();
+ for (size_t i = 0; i < Config.lines_scrolled; ++i)
+ w->Scroll(NC::wDown);
+ }
+ else if (me.bstate & BUTTON4_PRESSED)
+ {
+ if (Config.mouse_list_scroll_whole_page)
+ w->Scroll(NC::wPageUp);
+ else
+ for (size_t i = 0; i < Config.lines_scrolled; ++i)
+ w->Scroll(NC::wUp);
}
- (myScreen->*f)();
}
-void UpdateInactiveScreen(BasicScreen *screen_to_be_set)
+void ScrollpadMouseButtonPressed(NC::Scrollpad *w, MEVENT me)
{
- if (myInactiveScreen && myLockedScreen != myInactiveScreen && myLockedScreen == screen_to_be_set)
+ if (me.bstate & BUTTON2_PRESSED)
{
- // if we're here, the following conditions are (or at least should be) met:
- // 1. screen is split (myInactiveScreen is not null)
- // 2. current screen (myScreen) is not splittable, ie. is stacked on top of split screens
- // 3. current screen was activated while master screen was active
- // 4. we are returning to master screen
- // in such case we want to keep slave screen visible, so we never set it to null
- // as in "else" case. we also need to refresh it and redraw separator between
- // them as stacked screen probably has overwritten part ot it.
- myInactiveScreen->Refresh();
- DrawScreenSeparator(COLS*Config.locked_screen_width_part);
+ for (size_t i = 0; i < Config.lines_scrolled; ++i)
+ w->Scroll(NC::wDown);
}
- else
+ else if (me.bstate & BUTTON4_PRESSED)
{
- if (myLockedScreen == screen_to_be_set)
- myInactiveScreen = 0;
- else
- myInactiveScreen = myLockedScreen;
+ for (size_t i = 0; i < Config.lines_scrolled; ++i)
+ w->Scroll(NC::wUp);
}
}
-bool isVisible(BasicScreen *screen)
-{
- assert(screen != 0);
- if (myLockedScreen && myScreen->isMergable())
- return screen == myScreen || screen == myInactiveScreen || screen == myLockedScreen;
- else
- return screen == myScreen;
-}
+/***********************************************************************/
void BasicScreen::GetWindowResizeParams(size_t &x_offset, size_t &width, bool adjust_locked_screen)
{
@@ -116,8 +106,8 @@ bool BasicScreen::Lock()
return false;
if (isLockable())
{
- myLockedScreen = this;
- return true;
+ myLockedScreen = this;
+ return true;
}
else
return false;
@@ -131,3 +121,53 @@ void BasicScreen::Unlock()
myLockedScreen = 0;
myInactiveScreen = 0;
}
+
+/***********************************************************************/
+
+void ApplyToVisibleWindows(void (BasicScreen::*f)())
+{
+ if (myLockedScreen && myScreen->isMergable())
+ {
+ if (myScreen == myLockedScreen)
+ {
+ if (myInactiveScreen)
+ (myInactiveScreen->*f)();
+ }
+ else
+ (myLockedScreen->*f)();
+ }
+ (myScreen->*f)();
+}
+
+void UpdateInactiveScreen(BasicScreen *screen_to_be_set)
+{
+ if (myInactiveScreen && myLockedScreen != myInactiveScreen && myLockedScreen == screen_to_be_set)
+ {
+ // if we're here, the following conditions are (or at least should be) met:
+ // 1. screen is split (myInactiveScreen is not null)
+ // 2. current screen (myScreen) is not splittable, ie. is stacked on top of split screens
+ // 3. current screen was activated while master screen was active
+ // 4. we are returning to master screen
+ // in such case we want to keep slave screen visible, so we never set it to null
+ // as in "else" case. we also need to refresh it and redraw separator between
+ // them as stacked screen probably has overwritten part ot it.
+ myInactiveScreen->Refresh();
+ DrawScreenSeparator(COLS*Config.locked_screen_width_part);
+ }
+ else
+ {
+ if (myLockedScreen == screen_to_be_set)
+ myInactiveScreen = 0;
+ else
+ myInactiveScreen = myLockedScreen;
+ }
+}
+
+bool isVisible(BasicScreen *screen)
+{
+ assert(screen != 0);
+ if (myLockedScreen && myScreen->isMergable())
+ return screen == myScreen || screen == myInactiveScreen || screen == myLockedScreen;
+ else
+ return screen == myScreen;
+}