Permalink
Browse files

Move Emulator::{open,close} to Display

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information...
1 parent ba8d013 commit 03217ddb5a2133698de0d38a10f8cfd879b9be0b @andersk andersk committed with keithw Jan 28, 2013
@@ -232,7 +232,7 @@ void emulate_terminal( int fd )
sel.add_fd( fd );
sel.add_signal( SIGWINCH );
- swrite( STDOUT_FILENO, Terminal::Emulator::open().c_str() );
+ swrite( STDOUT_FILENO, display.open().c_str() );
int timeout = -1;
@@ -315,5 +315,5 @@ void emulate_terminal( int fd )
std::string update = display.new_frame( true, state, complete.get_fb() );
swrite( STDOUT_FILENO, update.c_str() );
- swrite( STDOUT_FILENO, Terminal::Emulator::close().c_str() );
+ swrite( STDOUT_FILENO, display.close().c_str() );
}
@@ -71,7 +71,7 @@ void STMClient::resume( void )
}
/* Put terminal in application-cursor-key mode */
- swrite( STDOUT_FILENO, Terminal::Emulator::open().c_str() );
+ swrite( STDOUT_FILENO, display.open().c_str() );
/* Flag that outer terminal state is unknown */
repaint_requested = true;
@@ -114,7 +114,7 @@ void STMClient::init( void )
}
/* Put terminal in application-cursor-key mode */
- swrite( STDOUT_FILENO, Terminal::Emulator::open().c_str() );
+ swrite( STDOUT_FILENO, display.open().c_str() );
/* Add our name to window title */
if ( !getenv( "MOSH_TITLE_NOPREFIX" ) ) {
@@ -135,7 +135,7 @@ void STMClient::shutdown( void )
output_new_frame();
/* Restore terminal and terminal-driver state */
- swrite( STDOUT_FILENO, Terminal::Emulator::close().c_str() );
+ swrite( STDOUT_FILENO, display.close().c_str() );
if ( tcsetattr( STDIN_FILENO, TCSANOW, &saved_termios ) < 0 ) {
perror( "tcsetattr" );
@@ -268,7 +268,7 @@ bool STMClient::process_user_input( int fd )
}
} else if ( the_byte == 0x1a ) { /* Suspend sequence is Ctrl-^ Ctrl-Z */
/* Restore terminal and terminal-driver state */
- swrite( STDOUT_FILENO, Terminal::Emulator::close().c_str() );
+ swrite( STDOUT_FILENO, display.close().c_str() );
if ( tcsetattr( STDIN_FILENO, TCSANOW, &saved_termios ) < 0 ) {
perror( "tcsetattr" );
@@ -163,17 +163,6 @@ void Emulator::Esc_dispatch( const Parser::Esc_Dispatch *act )
}
}
-std::string Emulator::open( void )
-{
- char appmode[ 6 ] = { 0x1b, '[', '?', '1', 'h', 0 };
- return std::string( appmode );
-}
-
-std::string Emulator::close( void )
-{
- return std::string( "\033[?1l\033[0m\033[?25h" );
-}
-
void Emulator::resize( size_t s_width, size_t s_height )
{
fb.resize( s_width, s_height );
@@ -78,9 +78,6 @@ namespace Terminal {
std::string read_octets_to_host( void );
- static std::string open( void ); /* put user cursor keys in application mode */
- static std::string close( void ); /* restore user cursor keys */
-
const Framebuffer & get_fb( void ) const { return fb; }
bool operator==( Emulator const &x ) const;
@@ -44,6 +44,16 @@ static const Renditions & initial_rendition( void )
return blank;
}
+std::string Display::open() const
+{
+ return std::string( "\033[?1h" );
+}
+
+std::string Display::close() const
+{
+ return std::string( "\033[?1l\033[0m\033[?25h" );
+}
+
std::string Display::new_frame( bool initialized, const Framebuffer &last, const Framebuffer &f ) const
{
FrameState frame( last );
@@ -79,6 +79,9 @@ namespace Terminal {
public:
void downgrade( Framebuffer &f ) const { if ( posterize_colors ) { f.posterize(); } }
+ std::string open() const;
+ std::string close() const;
+
std::string new_frame( bool initialized, const Framebuffer &last, const Framebuffer &f ) const;
Display( bool use_environment );

0 comments on commit 03217dd

Please sign in to comment.