mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-01 10:40:20 +03:00
WIP eterm.
This commit is contained in:
+36
-11
@@ -4,18 +4,43 @@
|
||||
EE::Window::Window* win = NULL;
|
||||
std::shared_ptr<ETerminalDisplay> terminal = nullptr;
|
||||
|
||||
void inputCallback( InputEvent* event ) {
|
||||
if ( !terminal )
|
||||
return;
|
||||
|
||||
switch ( event->Type ) {
|
||||
case InputEvent::Window: {
|
||||
break;
|
||||
}
|
||||
case InputEvent::KeyUp:
|
||||
|
||||
break;
|
||||
case InputEvent::KeyDown:
|
||||
terminal->onKeyDown( event->key.keysym.sym, event->key.keysym.unicode,
|
||||
event->key.keysym.mod, event->key.keysym.scancode );
|
||||
break;
|
||||
case InputEvent::TextInput:
|
||||
terminal->onTextInput( event->text.text );
|
||||
case InputEvent::SysWM:
|
||||
case InputEvent::VideoResize:
|
||||
case InputEvent::VideoExpose: {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tryInitTerminal( Font* fontDefault ) {
|
||||
if ( !terminal || terminal->HasTerminated() ) {
|
||||
auto spacingChar = fontDefault->getGlyph( 'A', 12, false );
|
||||
auto charWidth = spacingChar.advance;
|
||||
auto charHeight = 12;
|
||||
auto fontSize = 15;
|
||||
auto charWidth = fontDefault->getGlyph( 'A', fontSize, false ).advance;
|
||||
auto charHeight = terminal ? terminal->getFontSize() : fontSize;
|
||||
Sizef contentRegion = win->getSize().asFloat();
|
||||
|
||||
auto columns = (int)std::floor( std::max( 1.0f, contentRegion.x / charWidth ) );
|
||||
auto rows = (int)std::floor( std::max( 1.0f, contentRegion.y / charHeight ) );
|
||||
|
||||
terminal =
|
||||
ETerminalDisplay::Create( win, fontDefault, columns, rows, "/bin/sh", {}, "", 0 );
|
||||
ETerminalDisplay::Create( win, fontDefault, columns, rows, "/usr/bin/fish", {}, "", 0 );
|
||||
terminal->setFontSize( charHeight );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +49,6 @@ void mainLoop() {
|
||||
|
||||
win->getInput()->update();
|
||||
|
||||
if ( win->getInput()->isKeyDown( KEY_ESCAPE ) ) {
|
||||
win->close();
|
||||
}
|
||||
|
||||
if ( terminal ) {
|
||||
terminal->Update();
|
||||
|
||||
@@ -38,8 +59,12 @@ void mainLoop() {
|
||||
}
|
||||
|
||||
EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
win = Engine::instance()->createWindow( WindowSettings( 960, 640, "eepp - Empty Window" ),
|
||||
ContextSettings( true ) );
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
|
||||
win = Engine::instance()->createWindow(
|
||||
WindowSettings( 1280, 720, "eterm", WindowStyle::Default, WindowBackend::Default, 32,
|
||||
"assets/icon/ee.png" ),
|
||||
ContextSettings( true ) );
|
||||
|
||||
if ( win->isOpen() ) {
|
||||
win->setClearColor( RGB( 50, 50, 50 ) );
|
||||
@@ -49,7 +74,7 @@ EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
|
||||
tryInitTerminal( fontMono );
|
||||
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
win->getInput()->pushCallback( &inputCallback );
|
||||
|
||||
win->runMainLoop( &mainLoop );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user