static bool TryQConsole( void ) { struct _psinfo psinfo; struct _sidinfo info; struct _dev_info_entry dev; char *ptr; const char *term; if( qnx_psinfo( PROC_PID, getpid(), &psinfo, 0, 0 ) != getpid() ) { StartupErr( "unable to obtain process information" ); } if( qnx_sid_query( PROC_PID, psinfo.sid, &info ) != psinfo.sid ) { StartupErr( "unable to obtain console name" ); } ptr = info.tty_name + strlen( info.tty_name ); for( ;; ) { --ptr; if( *ptr < '0' || *ptr > '9' ) { break; } } if( DbgConsole != 0 ) { ptr[1] = '0' + DbgConsole / 10; ptr[2] = '0' + DbgConsole % 10; ptr += 2; } ptr[1] = NULLCHAR; DbgConHandle = open( info.tty_name, O_RDWR ); if( DbgConHandle == -1 ) { StartupErr( "unable to open system console" ); } term = getenv( "TERM" ); if( term != NULL && strcmp( term, "qnxw" ) == 0 ) { /* in QNX windows */ #define PROP_STRING "\033\"pwd\"" write( DbgConHandle, PROP_STRING, sizeof( PROP_STRING ) - 1 ); } ConCtrl = console_open( DbgConHandle, O_WRONLY ); if( ConCtrl == NULL ) { close( DbgConHandle ); return( false ); } if( dev_info( DbgConHandle, &dev ) == -1 ) { StartupErr( "unable to obtain console information" ); } DbgConsole = dev.unit; console_size( ConCtrl, DbgConsole, 0, 0, &PrevLines, &PrevColumns ); console_size( ConCtrl, DbgConsole, DbgLines, DbgColumns, 0, 0 ); InitConsole = console_active( ConCtrl, -1 ); return( true ); }
void console_clearstatusline() { int rows = 0; int cols = 0; console_size(&rows, &cols); console_gotoxy(0, rows); printf("\033[K\033[0m"); }
void console_statusline(const char *text1, const char *text2) { int rows = 0; int cols = 0; console_size(&rows, &cols); console_gotoxy(0, rows); printf("\033[1m\033[7m%s%s\033[K\033[0m", text1, text2); }
/* * ScreenInit - get screen info */ void ScreenInit( void ) { struct _osinfo info; int rows, cols; unsigned size; unsigned seg; vi_rc rc; QNXCon = console_open( QNXConHandle, O_WRONLY ); if( QNXCon == NULL ) { // FatalError( ERR_WIND_NO_MORE_WINDOWS ); ChangeDirectory( HomeDirectory ); exit( 0 ); } if( console_size( QNXCon, QNXConsole, 0, 0, &rows, &cols ) != 0 ) { console_close( QNXCon ); FatalError( ERR_WIND_NO_MORE_WINDOWS ); } rc = BIOSKeyboardInit(); if( rc != ERR_NO_ERR ) { console_close( QNXCon ); FatalError( rc ); } EditVars.WindMaxWidth = cols; EditVars.WindMaxHeight = rows; qnx_osinfo( 0, &info ); switch( info.primary_monitor ) { case _MONITOR_PGS: case _MONITOR_CGA: case _MONITOR_PS30_COLOR: case _MONITOR_EGA_COLOR: case _MONITOR_VGA_COLOR: EditFlags.Color = TRUE; break; case _MONITOR_EGA_MONO: case _MONITOR_VGA_MONO: case _MONITOR_PS30_MONO: EditFlags.BlackAndWhite = TRUE; break; default: EditFlags.Monocolor = TRUE; break; } size = cols * rows * sizeof( char_info ); seg = qnx_segment_alloc( size ); Scrn = MK_FP( seg, 0 ); ScreenPage( 0 ); } /* ScreenInit */
void FiniScreen( void ) { if( _IsOn( SW_USE_MOUSE ) ) GUIFiniMouse(); uistop(); switch( ConMode ) { case C_QCON: console_active( ConCtrl, InitConsole ); console_size( ConCtrl, DbgConsole, PrevLines, PrevColumns, NULL, NULL ); console_close( ConCtrl ); break; case C_XWIN: signal( SIGHUP, SIG_IGN ); kill( XQshPid, SIGTERM ); break; } }
static bool setupscrnbuff( void ) /*******************************/ { int rows, cols; LP_PIXEL scrn; size_t num; int i; if( console_size( UIConCtrl, UIConsole, 0, 0, &rows, &cols ) != 0 ) { return( false ); } UIData->width = cols; UIData->height = rows; num = UIData->width * UIData->height * 2; scrn = UIData->screen.origin; #if defined( __386__ ) scrn = realloc( scrn, num ); if( scrn == NULL ) return( false ); #else { unsigned seg; if( scrn == NULL ) { seg = qnx_segment_alloc( num ); } else { seg = qnx_segment_realloc( FP_SEG( scrn ), num ); } if( seg == -1 ) return( false ); scrn = MK_FP( seg, 0 ); } #endif num /= 2; for( i = 0; i < num; ++i ) { scrn[i].ch = ' '; /* a space with normal attributes */ scrn[i].attr = 7; /* a space with normal attributes */ } UIData->screen.origin = scrn; UIData->screen.increment = UIData->width; return( true ); }