Browse Source

neercs: minimalist keyboard support.

master
Sam Hocevar 12 years ago
parent
commit
8f31334519
1 changed files with 32 additions and 6 deletions
  1. +32
    -6
      neercs/term/term.cpp

+ 32
- 6
neercs/term/term.cpp View File

@@ -24,18 +24,17 @@ using namespace lol;
#include "term.h" #include "term.h"


Term::Term(ivec2 size) Term::Term(ivec2 size)
: m_time(0.f)
: m_pty(0),
m_caca(caca_create_canvas(size.x, size.y)),
m_size(size),
m_title(0),
m_time(0.f)
{ {
m_caca = caca_create_canvas(size.x, size.y);

#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H #if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
m_pty = new Pty(); m_pty = new Pty();
char const *shell = getenv("SHELL"); char const *shell = getenv("SHELL");
if (!shell) if (!shell)
shell = "/bin/sh"; shell = "/bin/sh";
shell = "cacaclock";
shell = "cacafire";
shell = "cacademo";
m_pty->Run(shell, size); m_pty->Run(shell, size);
#endif #endif
} }
@@ -45,6 +44,33 @@ void Term::TickGame(float seconds)
Entity::TickGame(seconds); Entity::TickGame(seconds);


#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H #if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
bool have_ctrl = Input::GetStatus(Key::LeftCtrl)
|| Input::GetStatus(Key::RightCtrl);
bool have_shift = Input::GetStatus(Key::LeftShift)
|| Input::GetStatus(Key::RightShift);

for (int i = 0x0; i < 0x7f; ++i)
{
if (Input::WasPressed((Key::Value)i))
{
if (have_ctrl && i >= 'a' && i <= 'z')
{
char c = i + 1 - 'a';
m_pty->WriteData(&c, 1);
}
else if (have_shift && i >= 'a' && i <= 'z')
{
char c = i + 'A' - 'a';
m_pty->WriteData(&c, 1);
}
else
{
char c = i;
m_pty->WriteData(&c, 1);
}
}
}

/* This is the real terminal code */ /* This is the real terminal code */
/* XXX: for now we draw fancy shit */ /* XXX: for now we draw fancy shit */
m_time += seconds; m_time += seconds;


Loading…
Cancel
Save