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