added HorizontalWindowManager
to DemoApp
This commit is contained in:
parent
4fb2e6a976
commit
9ddb769cb4
|
@ -13,7 +13,9 @@ set(CMAKE_CXX_STANDARD 17)
|
||||||
include(CTest)
|
include(CTest)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
add_library(kNCurses Window.cpp PtyWindow.cpp SingleUserInput.cpp Debug.cpp TilingWindowManager.cpp VerticalTilingWindowManager.cpp)
|
add_library(kNCurses Window.cpp PtyWindow.cpp SingleUserInput.cpp Debug.cpp
|
||||||
|
TilingWindowManager.cpp VerticalTilingWindowManager.cpp
|
||||||
|
HorizontalTilingWindowManager.cpp)
|
||||||
|
|
||||||
### path to own system includes
|
### path to own system includes
|
||||||
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/include")
|
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/include")
|
||||||
|
@ -44,8 +46,15 @@ target_link_libraries(kNCursesDemoApp kNCurses)
|
||||||
|
|
||||||
### installation and packaging
|
### installation and packaging
|
||||||
set(NCURSES_SYSTEM_INCLUDE "include/kNCurses")
|
set(NCURSES_SYSTEM_INCLUDE "include/kNCurses")
|
||||||
set_target_properties(kNCurses PROPERTIES PUBLIC_HEADER "${NCURSES_SYSTEM_INCLUDE}/Window.hpp;${NCURSES_SYSTEM_INCLUDE}/SingleUserInput.hpp;${NCURSES_SYSTEM_INCLUDE}/PtyWindow.hpp;${NCURSES_SYSTEM_INCLUDE}/VerticalTilingWindowManager.hpp;${NCURSES_SYSTEM_INCLUDE}/TilingWindowManager.hpp;"
|
set_target_properties(kNCurses PROPERTIES
|
||||||
VERSION "${CMAKE_PROJECT_VERSION}")
|
PUBLIC_HEADER "${NCURSES_SYSTEM_INCLUDE}/Window.hpp;
|
||||||
|
${NCURSES_SYSTEM_INCLUDE}/SingleUserInput.hpp;
|
||||||
|
${NCURSES_SYSTEM_INCLUDE}/PtyWindow.hpp;
|
||||||
|
${NCURSES_SYSTEM_INCLUDE}/TilingWindowManager.hpp;
|
||||||
|
${NCURSES_SYSTEM_INCLUDE}/VerticalTilingWindowManager.hpp;
|
||||||
|
${NCURSES_SYSTEM_INCLUDE}/HorizontalTilingWindowManager.hpp;
|
||||||
|
"
|
||||||
|
VERSION "${CMAKE_PROJECT_VERSION}")
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS kNCurses ARCHIVE
|
install(TARGETS kNCurses ARCHIVE
|
||||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kNCurses/")
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kNCurses/")
|
||||||
|
|
20
DemoApp.cpp
20
DemoApp.cpp
|
@ -5,6 +5,7 @@
|
||||||
#include "DemoApp.hpp"
|
#include "DemoApp.hpp"
|
||||||
#include "Debug.hpp"
|
#include "Debug.hpp"
|
||||||
#include <kNCurses/VerticalTilingWindowManager.hpp>
|
#include <kNCurses/VerticalTilingWindowManager.hpp>
|
||||||
|
#include <kNCurses/HorizontalTilingWindowManager.hpp>
|
||||||
#include <kNCurses/Window.hpp>
|
#include <kNCurses/Window.hpp>
|
||||||
#include <kNCurses/PtyWindow.hpp>
|
#include <kNCurses/PtyWindow.hpp>
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ namespace krikkel::NCurses
|
||||||
int DemoApp::run()
|
int DemoApp::run()
|
||||||
{
|
{
|
||||||
setUpWindows();
|
setUpWindows();
|
||||||
|
forkShell();
|
||||||
mainLoop();
|
mainLoop();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -31,16 +33,26 @@ namespace krikkel::NCurses
|
||||||
|
|
||||||
void DemoApp::setUpWindows()
|
void DemoApp::setUpWindows()
|
||||||
{
|
{
|
||||||
windowManager = new VerticalTilingWindowManager(Root_Window, &ncursesMutex);
|
windowManager
|
||||||
|
= new VerticalTilingWindowManager(Root_Window, &ncursesMutex);
|
||||||
|
|
||||||
dummyWindowTop = new Window(windowManager);
|
dummyWindowTop = new Window(windowManager);
|
||||||
dummyWindowTop->move(0, 0);
|
|
||||||
ptyWindow = new PtyWindow(&ncursesMutex, 0, 0, 0, 0);
|
ptyWindow = new PtyWindow(&ncursesMutex, 0, 0, 0, 0);
|
||||||
windowManager->addWindow(ptyWindow);
|
windowManager->addWindow(ptyWindow);
|
||||||
dummyWindowBottom = new Window(windowManager);
|
dummyWindowBottom = new Window(windowManager);
|
||||||
windowManager->updateLayout();
|
windowManager->updateLayout();
|
||||||
windowManager->refresh();
|
windowManager->refresh();
|
||||||
|
|
||||||
|
topWindowManager
|
||||||
|
= new HorizontalTilingWindowManager(dummyWindowTop, &ncursesMutex);
|
||||||
|
dummyWindowTopLeft = new Window(topWindowManager);
|
||||||
|
dummyWindowTopRight = new Window(topWindowManager);
|
||||||
|
topWindowManager->updateLayout();
|
||||||
|
topWindowManager->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemoApp::forkShell()
|
||||||
|
{
|
||||||
if(fork() == 0)
|
if(fork() == 0)
|
||||||
{
|
{
|
||||||
const char *shellPath = getenv("SHELL");
|
const char *shellPath = getenv("SHELL");
|
||||||
|
@ -69,8 +81,8 @@ namespace krikkel::NCurses
|
||||||
ptyWindow->writeUnicodeCharToClient(input.getRawInput());
|
ptyWindow->writeUnicodeCharToClient(input.getRawInput());
|
||||||
{
|
{
|
||||||
scoped_lock lock(ncursesMutex);
|
scoped_lock lock(ncursesMutex);
|
||||||
dummyWindowTop->addch(input.getRawInput());
|
dummyWindowTopRight->addch(input.getRawInput());
|
||||||
dummyWindowTop->refresh();
|
dummyWindowTopRight->refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(input.isFunctionKey())
|
if(input.isFunctionKey())
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
namespace krikkel::NCurses
|
namespace krikkel::NCurses
|
||||||
{
|
{
|
||||||
class VerticalTilingWindowManager;
|
class VerticalTilingWindowManager;
|
||||||
|
class HorizontalTilingWindowManager;
|
||||||
class Window;
|
class Window;
|
||||||
class PtyWindow;
|
class PtyWindow;
|
||||||
|
|
||||||
|
@ -22,12 +23,15 @@ namespace krikkel::NCurses
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VerticalTilingWindowManager *windowManager;
|
VerticalTilingWindowManager *windowManager;
|
||||||
Window *dummyWindowTop, *dummyWindowBottom;
|
HorizontalTilingWindowManager *topWindowManager;
|
||||||
|
Window *dummyWindowTop, *dummyWindowBottom, *dummyWindowTopLeft,
|
||||||
|
*dummyWindowTopRight;
|
||||||
PtyWindow *ptyWindow;
|
PtyWindow *ptyWindow;
|
||||||
std::recursive_mutex ncursesMutex;
|
std::recursive_mutex ncursesMutex;
|
||||||
|
|
||||||
int run() override;
|
int run() override;
|
||||||
void setUpWindows();
|
void setUpWindows();
|
||||||
|
void forkShell();
|
||||||
void mainLoop();
|
void mainLoop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue