Exemple #1
0
Console::Console(const Rect& bounds)
	: CliWindow(bounds)
	, _cursor(_canvas.Buffer())
	, _tab(4)
{
	ResetAttributes();
	Erase(BOTH, false);
}
// ---------------------------------------------------------------------------
// CRfsFileMan::Delete
// ---------------------------------------------------------------------------
//
TInt CRfsFileMan::Delete( const TDesC& aFullPath, const TEntry& aEntry )
    {
    FUNC_LOG;
    INFO_1( "Delete '%S'", &aFullPath );

    TBool isDir( aEntry.IsDir() );
    TInt err( isDir ? iFs.RmDir( aFullPath ) : iFs.Delete( aFullPath ) );
    if ( err == KErrAccessDenied )
        {
        ResetAttributes( aFullPath, aEntry );
        err = isDir ? iFs.RmDir( aFullPath ) : iFs.Delete( aFullPath );
        }
    ERROR_1( err, "Failed to delete '%S'", &aFullPath );
    return err;
    }
TInt CVtConsoleOutputController::ClearScreen()
	{
	TInt err = KErrInUse;
	if (iMode == ConsoleMode::EText)
		{
		_LIT8(KResetTerminal, "\x1b" "c" "\x1b" "[?7h"); // reset console, then enable line wrapping
		err = iOutput.Output(KResetTerminal);
		if (err == KErrNone)
			{
			User::After(100000); // It seems that TeraTerm doesn't like receiving attribute changes too soon after a terminal reset (tends to ignore the attributes).
			err = ResetAttributes();
			if (err == KErrNone)
				{
				_LIT8(KEscapeClearScreen, "\x1b[2J\x1b[01;01H");
				err = iOutput.Output(KEscapeClearScreen);
				if (err == KErrNone)
					{
					iCursorTracker->Reset();
					}
				}
			}
		}
	return err;
	}
Exemple #4
0
/// @todo Check boundaries
bool
Console::AnsiEscFilter(const char c)
{
	if (_ansiBufferPos == 0 && c == (char)0x9B) {
		_ansiBufferPos = 2;
		return true;
	}else if (_ansiBufferPos == 0 && c == (char)0x1B) {
		_ansiBufferPos = 1;
		return true;
	}else if (_ansiBufferPos == 1) {
		if (c == '[') {
			_ansiBufferPos = 2;
			return true;
		} else {
			_ansiBufferPos = 0;
			return false;
		}
	}else if (_ansiBufferPos > 1) {
		if (isdigit(c) || c == ';') {
			_ansiBuffer[_ansiBufferPos++] = c;
		} else {
			_ansiBuffer[_ansiBufferPos] = '\0';
			_ansiBufferPos = 0;

			long params[10] = {0};
			const int parQty = AnsiEscParseParams(&_ansiBuffer[2], params);
			switch(c) {
				case 'c':	// Reset Device
					ResetAttributes();
					Erase(BOTH, false);
					break;
				case 'h':
					if (parQty == 1 && params[0] == 7)
						SetLineWrap(true);
					break;
				case 'l':
					if (parQty == 1 && params[0] == 7)
						SetLineWrap(false);
					break;
				case 'A':	// [nA Cursor Up
					if (!parQty)
						params[0] = 1;
					//
					_cursor -= _canvas.Size().x*params[0];
					UpdateCursor();
					break;
				case 'B':	// [nB Cursor Down
					if (!parQty)
						params[0] = 1;
					//
					_cursor += _canvas.Size().x*params[0];
					UpdateCursor();
					break;
				case 'C':	// [nC Cursor Forward
					if (!parQty)
						params[0] = 1;
					//
					_cursor += params[0];
					UpdateCursor();
					break;
				case 'D':	// [nD Cursor Backward
					if (!parQty)
						params[0] = 1;
					//
					_cursor -= params[0];
					UpdateCursor();
					break;
				case 'H':	// [y;xH Cursor Home
				case 'f':	// [y;xf Force Cursor Position
					if (parQty < 2) {
						params[0] = 0;	// Y
						params[1] = 0;	// X
					}
					//
					_cursor = _canvas.Buffer() + _canvas.Size().x*params[0] + params[1];
					UpdateCursor();
					break;
				case 's':	// [s Save Cursor
					_ansiCursorStack.Push(_cursor);
					break;
				case 'u':	// [u Unsave Cursor
					_cursor = _ansiCursorStack.Pop();
					UpdateCursor();
					break;
				case 'J':	// [nJ
					if (parQty == 0)
						params[0] = 0;
					Erase(static_cast<EraseDirection>(params[0]), false);
					break;
				case 'K':	// [nK
					if (parQty == 0)
						params[0] = 0;
					Erase(static_cast<EraseDirection>(params[0]), true);
					break;
				case 'm':	// [p1;..;pNm
					if (!parQty) {
						ResetAttributes();
					} else {
						for(int i=0; i<parQty; ++i) {
							switch(params[i]) {
								case  0:	ResetAttributes();		break;
								case  1:	SetBold(true);			break;
								//case  2:	SetFaint(true);			break;
								//case  3:	SetItalic(true);		break;
								//case  4:	SetUnderline(true);		break;
								case  5:	SetBlink(true);			break;
								//case  6:	SetRapidBlink(true);	break;
								case  7:	SetReverseVideo(true);	break;
								//case  8:	SetInvisible(true);		break;
								//case 48:	SetSubscript(true);		break;
								//case 49:	SetSuperscript(true);	break;

								case 30:	Foreground(BLACK);	break;
								case 31:	Foreground(RED);	break;
								case 32:	Foreground(GREEN);	break;
								case 33:	Foreground(BROWN);	break;
								case 34:	Foreground(BLUE);	break;
								case 35:	Foreground(MAGENTA);break;
								case 36:	Foreground(CYAN);	break;
								case 37:	Foreground(WHITE);	break;
								case 90:	Foreground(GRAY);	break;
								case 91:	Foreground(RED_B);	break;
								case 92:	Foreground(LIME);	break;
								case 93:	Foreground(YELLOW);	break;
								case 94:	Foreground(BLUE_B);	break;
								case 95:	Foreground(MAGENTA_B);break;
								case 96:	Foreground(CYAN_B);	break;
								case 97:	Foreground(WHITE_B);break;

								case 40:	Background(BLACK);	break;
								case 41:	Background(RED);	break;
								case 42:	Background(GREEN);	break;
								case 43:	Background(BROWN);	break;
								case 44:	Background(BLUE);	break;
								case 45:	Background(MAGENTA);break;
								case 46:	Background(CYAN);	break;
								case 47:	Background(WHITE);	break;
								case 100:	Background(GRAY);	break;
								case 101:	Background(RED_B);	break;
								case 102:	Background(LIME);	break;
								case 103:	Background(YELLOW);	break;
								case 104:	Background(BLUE_B);	break;
								case 105:	Background(MAGENTA_B);break;
								case 106:	Background(CYAN_B);	break;
								case 107:	Background(WHITE_B);break;
							}
						}
					}
					break;
				default:		//the command was not recognized
					char* p = _ansiBuffer;
					while(*p)
						PutChar(*p++);
					break;
			}
		}
		return true;
	}
	return false;
}
Exemple #5
0
ByteBuffer Image::Release()
{
    ResetAttributes();
    return std::move(data_);
}
Exemple #6
0
void Image::Reset()
{
    ResetAttributes();
    data_.reset();
}