git-svn-id: svn://db.shs.com.ru/pip@263 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
54
main.cpp
54
main.cpp
@@ -10,8 +10,8 @@
|
||||
#include "piserial.h"
|
||||
|
||||
|
||||
PIScreen screen;
|
||||
PIConnection conn;
|
||||
TilePICout cout_tile;
|
||||
|
||||
|
||||
const char conn_config[] =
|
||||
@@ -19,7 +19,12 @@ const char conn_config[] =
|
||||
device.test = ser://COM54:115200 #s\n\
|
||||
device.test.disconnectTimeout = 3.00000000 #f\n\
|
||||
[]\n";
|
||||
|
||||
class TileTerminal: public PIScreenTile {
|
||||
public:
|
||||
TileTerminal(PITerminal * t) {
|
||||
focus_flags = PIScreenTypes::CanHasFocus;
|
||||
term = t;
|
||||
}
|
||||
private:
|
||||
void drawEvent(PIScreenDrawer * d) {
|
||||
//piCout << "draw" << visible;
|
||||
@@ -28,38 +33,20 @@ private:
|
||||
d->fillRect(x_, y_, x_ + width_, y_ + height_, c);
|
||||
}
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) {
|
||||
//piCout << "key";
|
||||
//return false;
|
||||
if (key.key == '~') {
|
||||
cout_tile.content.clear();
|
||||
return true;
|
||||
}
|
||||
if (!term) return false;
|
||||
if (PITerminal::isSpecialKey(key.key)) term->write((PIKbdListener::SpecialKey)key.key, key.modifiers);
|
||||
else {
|
||||
PIByteArray ba;
|
||||
//ba << PIChar(key.key).toConcole1Byte();
|
||||
//piCout << key.key;
|
||||
ba = PIString(PIChar(key.key)).toUTF8();
|
||||
term->write(ba);
|
||||
}
|
||||
EVENT_HANDLER1(void, keyEv, PIKbdListener::KeyEvent, k) {
|
||||
piCoutObj << k.key;
|
||||
if (k.key == -20) {
|
||||
PIKbdListener::exiting = true;
|
||||
|
||||
}
|
||||
if (k.key == 's') {
|
||||
PISerial * ser = (PISerial *)conn.deviceByName("test");
|
||||
if (ser) {
|
||||
PIByteArray ba;
|
||||
ba << uchar(31) << uchar(230) << uchar(0xd) << uchar(0xa);
|
||||
piCoutObj << "send";
|
||||
ser->writeThreaded(ba);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EVENT_HANDLER2(void, recv, const PIString &, from, const PIByteArray &, data) {
|
||||
piCoutObj << from << PIString(data) << PICoutManipulators::Hex << data;
|
||||
}
|
||||
};
|
||||
term->write(key);
|
||||
}
|
||||
void resizeEvent(int w, int h) {
|
||||
if (!term) return;
|
||||
term->resize(w, h);
|
||||
}
|
||||
PITerminal * term;
|
||||
};
|
||||
|
||||
int main (int argc, char * argv[]) {
|
||||
/*const char cs[] = "this is text\e";
|
||||
@@ -75,7 +62,7 @@ int main (int argc, char * argv[]) {
|
||||
TileTerminal tt(&term);
|
||||
if (screen) {
|
||||
screen->rootTile()->addTile(&tt);
|
||||
screen->rootTile()->addTile(new TilePICout());
|
||||
screen->rootTile()->addTile(&cout_tile);
|
||||
screen->enableExitCapture();
|
||||
}
|
||||
tt.setFocus();
|
||||
@@ -102,6 +89,7 @@ int main (int argc, char * argv[]) {
|
||||
}
|
||||
if (screen) {
|
||||
screen->rootTile()->takeTile(&tt);
|
||||
screen->rootTile()->takeTile(&cout_tile);
|
||||
delete screen;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -25,9 +25,13 @@
|
||||
#else
|
||||
# include "piprocess.h"
|
||||
# include <csignal>
|
||||
# include <pty.h>
|
||||
# include <fcntl.h>
|
||||
# include <sys/ioctl.h>
|
||||
# if defined(QNX) || defined(BLACKBERRY)
|
||||
# include <unix.h>
|
||||
# else
|
||||
# include <pty.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -75,7 +79,6 @@ PRIVATE_DEFINITION_START(PITerminal)
|
||||
bool is_esc_seq, last_read;
|
||||
PIMap<int, bool> DEC;
|
||||
PIVector<PIVector<PIScreenTypes::Cell> > cells_save;
|
||||
termios desc;
|
||||
#endif
|
||||
PRIVATE_DEFINITION_END(PITerminal)
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
# ifdef BLACKBERRY
|
||||
# include <complex>
|
||||
# else
|
||||
# include <complex.h>
|
||||
# include <complex>
|
||||
# endif
|
||||
#else
|
||||
# include <complex>
|
||||
|
||||
@@ -137,7 +137,7 @@ bool PIThread::start(int timer_delay) {
|
||||
pthread_attr_destroy(&attr);
|
||||
if (ret == 0) {
|
||||
# ifdef MAC_OS
|
||||
pthread_threadid_np(thread, (__uint64_t*)&tid)
|
||||
pthread_threadid_np(thread, (__uint64_t*)&tid_)
|
||||
# else
|
||||
tid_ = thread;
|
||||
# endif
|
||||
@@ -173,7 +173,7 @@ bool PIThread::startOnce() {
|
||||
pthread_attr_destroy(&attr);
|
||||
if (ret == 0) {
|
||||
# ifdef MAC_OS
|
||||
pthread_threadid_np(thread, (__uint64_t*)&tid)
|
||||
pthread_threadid_np(thread, (__uint64_t*)&tid_)
|
||||
# else
|
||||
tid_ = thread;
|
||||
# endif
|
||||
|
||||
Reference in New Issue
Block a user