00001 00007 #include <cassert> 00008 00009 extern "C" { 00010 #include <slang.h> 00011 } 00012 00013 // Definição de métodos inline da classe Tecla: 00014 00015 inline Slang::Tecla::Tecla(TeclaEnum tecla) 00016 : tecla(tecla) { 00017 } 00018 00019 inline Slang::Tecla::operator Slang::Tecla::TeclaEnum() const { 00020 return tecla; 00021 } 00022 00023 inline char Slang::Tecla::comoChar() const 00024 { 00025 assert(eChar()); 00026 00027 return char(tecla); 00028 } 00029 00030 inline bool Slang::Tecla::eDeDeslocamento() const 00031 { 00032 return tecla == cima or tecla == baixo or tecla == esquerda or 00033 tecla == direita; 00034 } 00035 00036 inline bool Slang::Tecla::eChar() const 00037 { 00038 return (32 <= tecla and tecla < 127) or (160 <= tecla and tecla < 256); 00039 } 00040 00041 // Definição de métodos inline da classe Teclado: 00042 00043 inline Slang::Teclado::~Teclado() { 00044 // Terminação do slang: 00045 SLang_reset_tty(); 00046 } 00047 00048 inline bool 00049 Slang::Teclado::haTeclaDisponivel(int const decimos_de_segundo) const 00050 { 00051 return SLang_input_pending(decimos_de_segundo) != 0; 00052 } 00053 00054 inline Slang::Tecla Slang::Teclado::teclaLida() const 00055 { 00056 return tecla_lida; 00057 } 00058 00059 inline void Slang::Teclado::leProximaTeclaDisponivel() 00060 { 00061 tecla_lida = Tecla::TeclaEnum(SLkp_getkey()); 00062 } 00063 00064 inline void Slang::Teclado::descartaTeclasDisponiveis() 00065 { 00066 SLang_flush_input(); 00067 } 00068