Changeset 1880


Ignore:
Timestamp:
Sep 5, 2012, 10:08:36 PM (8 years ago)
Author:
sam
Message:

neercs: adapt PTY to canvas size.

Location:
trunk/tools/neercs/term
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/neercs/term/pty.cpp

    r1871 r1880  
    4242#include "neercs.h"
    4343
    44 Pty::Pty(ivec2 size)
     44Pty::Pty()
    4545  : m_fd(-1),
    4646    m_pid(-1),
    4747    m_unread_data(0),
    48     m_unread_len(0),
    49     m_size(size)
     48    m_unread_len(0)
    5049{
    5150    ;
     
    6261}
    6362
    64 void Pty::Run(char const *command)
     63void Pty::Run(char const *command, ivec2 size)
    6564{
    6665#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
     
    7978    else if (pid == 0)
    8079    {
    81         SetWindowSize(0, m_size);
     80        SetWindowSize(size, 0);
    8281
    8382        /* putenv() eats the string, they need to be writable */
     
    176175}
    177176
    178 void Pty::SetWindowSize(int64_t fd, ivec2 size)
     177void Pty::SetWindowSize(ivec2 size, int64_t fd /* = -1 */)
    179178{
    180179#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
     180    if (m_size == size)
     181        return;
     182
     183    if (fd < 0)
     184        fd = m_fd;
     185
    181186    m_size = size;
    182187
  • trunk/tools/neercs/term/pty.h

    r1871 r1880  
    99{
    1010public:
    11     Pty(ivec2 size);
     11    Pty();
    1212    ~Pty();
    1313
    14     void Run(char const *command);
     14    void Run(char const *command, ivec2 size);
    1515    size_t ReadData(char *data, size_t maxlen);
    1616    void UnreadData(char *data, size_t len);
    17     void SetWindowSize(int64_t fd, ivec2 size);
     17    void SetWindowSize(ivec2 size, int64_t fd = -1);
    1818
    1919private:
  • trunk/tools/neercs/term/term.cpp

    r1871 r1880  
    2121
    2222#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
    23     m_pty = new Pty(size);
     23    m_pty = new Pty();
    2424    char const *shell = getenv("SHELL");
    2525    if (!shell)
     
    2828    shell = "cacafire";
    2929    shell = "cacademo";
    30     m_pty->Run(shell);
     30    m_pty->Run(shell, size);
    3131#endif
    3232}
     
    4040    /* XXX: for now we draw fancy shit */
    4141    m_time += seconds;
     42
     43    m_pty->SetWindowSize(ivec2(caca_get_canvas_width(m_caca),
     44                               caca_get_canvas_height(m_caca)));
    4245
    4346    size_t total = 0;
Note: See TracChangeset for help on using the changeset viewer.