Przeglądaj źródła

neercs: ESC no longer quits; but closing the shell does.

master
Sam Hocevar 12 lat temu
rodzic
commit
71da6d07f9
4 zmienionych plików z 23 dodań i 9 usunięć
  1. +13
    -2
      neercs/term/pty.cpp
  2. +2
    -0
      neercs/term/pty.h
  3. +8
    -3
      neercs/term/term.cpp
  4. +0
    -4
      neercs/video/render.cpp

+ 13
- 2
neercs/term/pty.cpp Wyświetl plik

@@ -44,6 +44,7 @@ using namespace lol;
Pty::Pty()
: m_fd(-1),
m_pid(-1),
m_eof(false),
m_unread_data(0),
m_unread_len(0)
{
@@ -104,6 +105,11 @@ void Pty::Run(char const *command, ivec2 size)
#endif
}

bool Pty::IsEof() const
{
return m_eof;
}

size_t Pty::ReadData(char *data, size_t maxlen)
{
#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
@@ -141,14 +147,19 @@ size_t Pty::ReadData(char *data, size_t maxlen)
if (ret < 0)
{
Log::Error("cannot read from PTY\n");
m_eof = true;
return 0;
}

if (ret)
else if (ret)
{
if (FD_ISSET((int)m_fd, &fdset))
{
ssize_t nr = read((int)m_fd, data, maxlen);

/* Data available but zero-length read: EOF */
if (nr <= 0)
m_eof = true;

if (nr >= 0)
return nr;
}


+ 2
- 0
neercs/term/pty.h Wyświetl plik

@@ -12,6 +12,7 @@ public:
~Pty();

void Run(char const *command, ivec2 size);
bool IsEof() const;

size_t ReadData(char *data, size_t maxlen);
void UnreadData(char *data, size_t len);
@@ -22,6 +23,7 @@ public:
private:
int64_t m_fd;
int64_t m_pid;
bool m_eof;
char const *m_argv[2];
char *m_unread_data;
size_t m_unread_len;


+ 8
- 3
neercs/term/term.cpp Wyświetl plik

@@ -113,13 +113,18 @@ void Term::TickGame(float seconds)
}
}

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

if (m_pty->IsEof())
{
/* FIXME: we could do more interesting things here… */
Ticker::Shutdown();
}

m_pty->SetWindowSize(ivec2(caca_get_canvas_width(m_caca),
caca_get_canvas_height(m_caca)));

/* This is the real terminal code */
size_t total = 0;
for (;;)
{
@@ -248,4 +253,4 @@ void Term::DrawFancyShit()
caca_put_str(m_caca, 0, 2, "root@lol:~/ echo LOL");
caca_put_str(m_caca, 0, 3, "LOL");
caca_put_str(m_caca, 0, 4, "root@lol:~/");
}
}

+ 0
- 4
neercs/video/render.cpp Wyświetl plik

@@ -726,10 +726,6 @@ void Render::Pause()
void Render::TickDraw(float seconds)
{
/* keyboard manager */
if (Input::WasReleased(Key::Escape))
{
Ticker::Shutdown();
}
if (Input::WasPressed(Key::F1))
{
g_setup = !g_setup;


Ładowanie…
Anuluj
Zapisz