From 5b41331f1100c78541d87b7ad5a15d5652acb079 Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Sat, 9 Mar 2013 10:40:16 +0100 Subject: [PATCH] CodeStyle fixes, some refactoring and cleanup * Clear some codestyle issues catched by checker script; * Rename RestartDebugCapture to more consistent StartStopDebugCapture; * Updated Copyrights and authors lists, some occurences of the raw MIT licence text replaced with "under the terms of MIT licence" reference; * Fixes for x86_64 build. This is cumulative cleanup commit for series of Terminal refactoring changes I have introduced last time. No significant functional changes. --- src/apps/terminal/BasicTerminalBuffer.cpp | 62 ++++++++++----------- src/apps/terminal/BasicTerminalBuffer.h | 16 ++++-- src/apps/terminal/Colors.cpp | 24 ++++----- src/apps/terminal/Colors.h | 12 +++-- src/apps/terminal/HistoryBuffer.cpp | 5 ++ src/apps/terminal/PrefHandler.cpp | 15 ++++-- src/apps/terminal/PrefHandler.h | 7 ++- src/apps/terminal/Shell.cpp | 8 ++- src/apps/terminal/TermApp.cpp | 8 +-- src/apps/terminal/TermApp.h | 29 ++-------- src/apps/terminal/TermConst.h | 45 +++------------- src/apps/terminal/TermParse.cpp | 62 ++++++++++----------- src/apps/terminal/TermParse.h | 28 ++-------- src/apps/terminal/TermView.cpp | 66 ++++++++++------------- src/apps/terminal/TermView.h | 5 +- src/apps/terminal/TermWindow.cpp | 38 +++++++------ src/apps/terminal/TerminalBuffer.cpp | 9 +++- src/apps/terminal/TerminalBuffer.h | 5 ++ src/apps/terminal/TerminalLine.h | 5 ++ src/apps/terminal/VTPrsTbl.c | 39 ++++---------- src/apps/terminal/VTparse.h | 29 ++-------- 21 files changed, 220 insertions(+), 297 deletions(-) diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index 4f403df766..182551ef21 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -1,6 +1,11 @@ /* + * Copyright 2013, Haiku, Inc. All rights reserved. * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold, ingo_weinhold@gmx.de + * Siarzhuk Zharski, zharik@gmx.li */ #include "BasicTerminalBuffer.h" @@ -265,7 +270,6 @@ BasicTerminalBuffer::SynchronizeWith(const BasicTerminalBuffer* other, destLine->softBreak = sourceLine->softBreak; if (destLine->length > 0) { memcpy(destLine->cells, sourceLine->cells, -// destLine->length * sizeof(TerminalCell)); fWidth * sizeof(TerminalCell)); } } else { @@ -309,6 +313,7 @@ BasicTerminalBuffer::GetChar(int32 row, int32 column, UTF8Char& character, return A_CHAR; } + void BasicTerminalBuffer::GetCellAttributes(int32 row, int32 column, uint32& attributes, uint32& count) const @@ -319,16 +324,14 @@ BasicTerminalBuffer::GetCellAttributes(int32 row, int32 column, if (line == NULL || column < 0) return; - uint32 c = column; + int32 c = column; for (; c < fWidth; c++) { TerminalCell& cell = line->cells[c]; - if (c > column && attributes != cell.attributes) { + if (c > column && attributes != cell.attributes) break; - } attributes = cell.attributes; } count = c - column; -// printf("r:%d c:%d count:%d a:%x\n", row, column, count, attributes); } @@ -497,6 +500,7 @@ BasicTerminalBuffer::GetLineColor(int32 index) const return line != NULL ? line->attributes : 0; } + bool BasicTerminalBuffer::Find(const char* _pattern, const TermPos& start, bool forward, bool caseSensitive, bool matchWord, TermPos& _matchStart, @@ -728,7 +732,7 @@ BasicTerminalBuffer::InsertTab() if (x != fCursor.x) { TerminalLine* line = _LineAt(fCursor.y); for (int32 i = fCursor.x; i <= x; i++) { - line->cells[i].character = ' '; + line->cells[i].character = ' '; line->cells[i].attributes = fAttributes; } fCursor.x = x; @@ -784,35 +788,27 @@ void BasicTerminalBuffer::EraseCharsFrom(int32 first, int32 numChars) { TerminalLine* line = _LineAt(fCursor.y); - -/* if (IsAlternateScreenActive())*/ { - int32 end = min_c(first + numChars, fWidth); - for (int32 i = first; i < end; i++) - line->cells[i].attributes = fAttributes; - } - + + int32 end = min_c(first + numChars, fWidth); + for (int32 i = first; i < end; i++) + line->cells[i].attributes = fAttributes; + line->attributes = fAttributes; - _Invalidate(fCursor.y, fCursor.y); - -// if (fCursor.x >= line->length) -// return; - fSoftWrappedCursor = false; - int32 end = min_c(first + numChars, line->length); -// printf("%d:%d - %d|", fCursor.y, first, end); + end = min_c(first + numChars, line->length); if (first > 0 && IS_WIDTH(line->cells[first - 1].attributes)) first--; if (end > 0 && IS_WIDTH(line->cells[end - 1].attributes)) end++; -// printf("%d - %d\n", first, end); for (int32 i = first; i < end; i++) { line->cells[i].character = kSpaceChar; line->cells[i].attributes = fAttributes; } + _Invalidate(fCursor.y, fCursor.y); } @@ -887,8 +883,6 @@ BasicTerminalBuffer::DeleteChars(int32 numChars) line->length = fCursor.x; } -// line->attributes = fAttributes; - _Invalidate(fCursor.y, fCursor.y); } } @@ -1331,7 +1325,7 @@ BasicTerminalBuffer::_ResizeRewrap(int32 width, int32 height, sourceLine->cells + sourceX, toCopy * sizeof(TerminalCell)); destLine->length += toCopy; } - + destLine->attributes = sourceLine->attributes; bool nextDestLine = false; @@ -1572,12 +1566,9 @@ void BasicTerminalBuffer::_PadLineToCursor() { TerminalLine* line = _LineAt(fCursor.y); - if (line->length < fCursor.x) { - for (int32 i = line->length; i < fCursor.x; i++) { + if (line->length < fCursor.x) + for (int32 i = line->length; i < fCursor.x; i++) line->cells[i].character = kSpaceChar; -// line->cells[i].attributes = line->attributes; - } - } } @@ -1716,7 +1707,7 @@ BasicTerminalBuffer::MakeLinesSnapshots(time_t timeStamp, const char* fileName) break; } - size_t countLines = dumpHistory ? fHistory->Size() : fHeight; + int countLines = dumpHistory ? fHistory->Size() : fHeight; fprintf(fileOut, "> %s lines dump begin <\n", dumpHistory ? "History" : "Terminal"); @@ -1727,11 +1718,11 @@ BasicTerminalBuffer::MakeLinesSnapshots(time_t timeStamp, const char* fileName) : fScreen[_LineIndex(i)]; if (line == NULL) { - fprintf(fileOut, "line: %ld is NULL!!!\n", i); + fprintf(fileOut, "line: %d is NULL!!!\n", i); continue; } - fprintf(fileOut, "%02d:%02d:%08lx:\n", + fprintf(fileOut, "%02" B_PRId16 ":%02" B_PRId16 ":%08" B_PRIx32 ":\n", i, line->length, line->attributes); for (int j = 0; j < line->length; j++) fprintf(fileOut, "%c", line->cells[j].character.bytes[0]); @@ -1739,7 +1730,7 @@ BasicTerminalBuffer::MakeLinesSnapshots(time_t timeStamp, const char* fileName) fprintf(fileOut, "\n"); for (int s = 28; s >= 0; s -= 4) { for (int j = 0; j < fWidth; j++) - fprintf(fileOut, "%01lx", + fprintf(fileOut, "%01" B_PRIx32, (line->cells[j].attributes >> s) & 0x0F); fprintf(fileOut, "\n"); @@ -1751,14 +1742,15 @@ BasicTerminalBuffer::MakeLinesSnapshots(time_t timeStamp, const char* fileName) fprintf(fileOut, "> %s lines dump finished <\n", dumpHistory ? "History" : "Terminal"); - } while (dumpHistory = !dumpHistory); + dumpHistory = !dumpHistory; + } while (dumpHistory); fclose(fileOut); } void -BasicTerminalBuffer::RestartDebugCapture() +BasicTerminalBuffer::StartStopDebugCapture() { if (fCaptureFile >= 0) { close(fCaptureFile); diff --git a/src/apps/terminal/BasicTerminalBuffer.h b/src/apps/terminal/BasicTerminalBuffer.h index c5300d5aee..4275c9041f 100644 --- a/src/apps/terminal/BasicTerminalBuffer.h +++ b/src/apps/terminal/BasicTerminalBuffer.h @@ -1,6 +1,11 @@ /* + * Copyright 2013, Haiku, Inc. All rights reserved. * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold, ingo_weinhold@gmx.de + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef BASIC_TERMINAL_BUFFER_H #define BASIC_TERMINAL_BUFFER_H @@ -114,8 +119,8 @@ public: // snapshots and data capture for debugging void MakeLinesSnapshots(time_t timeStamp, const char* fileName); - void RestartDebugCapture(); - /*inline*/ void CaptureChar(char ch); + void StartStopDebugCapture(); + void CaptureChar(char ch); // insert chars/lines inline void InsertChar(UTF8Char c); @@ -183,7 +188,7 @@ protected: static TerminalLine** _AllocateLines(int32 width, int32 count); static void _FreeLines(TerminalLine** lines, int32 count); - void _ClearLines(int32 first, int32 last/*, uint32 attr = 0*/); //TODO attr + void _ClearLines(int32 first, int32 last); status_t _ResizeHistory(int32 width, int32 historyCapacity); @@ -272,7 +277,7 @@ BasicTerminalBuffer::SetAttributes(uint32 attributes) void BasicTerminalBuffer::PreserveAttributes(bool store) { - if (store) + if (store) fSavedAttributes = fAttributes; else fAttributes = fSavedAttributes; @@ -306,18 +311,21 @@ BasicTerminalBuffer::EraseChars(int32 numChars) EraseCharsFrom(fCursor.x, numChars); } + void BasicTerminalBuffer::DeleteColumns() { DeleteColumnsFrom(fCursor.x); } + void BasicTerminalBuffer::SetCursor(int32 x, int32 y) { _SetCursor(x, y, false); } + void BasicTerminalBuffer::SetCursorX(int32 x) { diff --git a/src/apps/terminal/Colors.cpp b/src/apps/terminal/Colors.cpp index b7a009214b..669d6b40c7 100644 --- a/src/apps/terminal/Colors.cpp +++ b/src/apps/terminal/Colors.cpp @@ -1,6 +1,10 @@ /* - * Copyright 2010-2012, Haiku, Inc. All rights reserved. + * Copyright 2010-2013, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. + * + * Authors: + * Stefano Ceccherini, stefano.ceccherini@gmail.com + * Siarzhuk Zharski, zharik@gmx.li */ @@ -8,7 +12,6 @@ #include #include -#include #include #include @@ -128,7 +131,8 @@ XColorsTable::XColorsTable() XColorsTable::~XColorsTable() { - // fTable is owned by BApplication - no need to free it. + // fTable as result of LoadResource call and owned + // by BApplication so no need to free it explicitly fTable = NULL; fCount = 0; } @@ -180,9 +184,9 @@ status_t XColorsTable::_LoadXColorsTable() { BResources* res = BApplication::AppResources(); - if (res == NULL) + if (res == NULL) return B_ERROR; - + size_t size = 0; fTable = (_XColorEntry*)res->LoadResource(B_RAW_TYPE, "XColorsTable", &size); if (fTable == NULL || size < sizeof(_XColorEntry)) { @@ -191,16 +195,6 @@ XColorsTable::_LoadXColorsTable() } fCount = size / sizeof(_XColorEntry); - -// printf("%ld; sizeof:%ld\n", fCount, sizeof(_XColorEntry)); - - for (size_t i = 0; i < fCount; i++) { - printf("%ld:%#010lx -> %d/%d/%d %d\n", - i, fTable[i].hash, fTable[i].color.red, - fTable[i].color.green, fTable[i].color.blue, - fTable[i].color.alpha); - } - return B_OK; } diff --git a/src/apps/terminal/Colors.h b/src/apps/terminal/Colors.h index fe45c272d7..1b83f1cbd0 100644 --- a/src/apps/terminal/Colors.h +++ b/src/apps/terminal/Colors.h @@ -1,6 +1,10 @@ /* - * Copyright 2010-2012, Haiku, Inc. All rights reserved. + * Copyright 2010-2013, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. + * + * Authors: + * Stefano Ceccherini, stefano.ceccherini@gmail.com + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef _COLORS_H #define _COLORS_H @@ -28,8 +32,8 @@ const uint kTermColorCount = 256; // Helper class handling XColorName/rgb:xxx/xxx/xxx -> rgb_color conversions. -// The source of XColorNames is wide available rgb.txt for X11 System. -// It is stored in "XColorsTable" application resource as array of +// The source of XColorNames is wide available rgb.txt for X11 System. +// It is stored in "XColorsTable" application resource as array of // "hash <-> rgb_color" pairs. The table is loaded only on demand. // Name hashes must be sorted to let lookup procedure work properly class XColorsTable { @@ -39,7 +43,7 @@ class XColorsTable { rgb_color color; }; -public: +public: XColorsTable(); ~XColorsTable(); diff --git a/src/apps/terminal/HistoryBuffer.cpp b/src/apps/terminal/HistoryBuffer.cpp index 9704af0426..3202c5a0af 100644 --- a/src/apps/terminal/HistoryBuffer.cpp +++ b/src/apps/terminal/HistoryBuffer.cpp @@ -1,6 +1,11 @@ /* + * Copyright 2013, Haiku, Inc. All rights reserved. * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold, ingo_weinhold@gmx.de + * Siarzhuk Zharski, zharik@gmx.li */ #include "HistoryBuffer.h" diff --git a/src/apps/terminal/PrefHandler.cpp b/src/apps/terminal/PrefHandler.cpp index c9e159c838..3f75d18cd4 100644 --- a/src/apps/terminal/PrefHandler.cpp +++ b/src/apps/terminal/PrefHandler.cpp @@ -1,10 +1,15 @@ /* - * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2013, Haiku, Inc. All Rights Reserved. * Copyright (c) 2004 Daniel Furrer * Copyright (c) 2003-4 Kian Duffy * Copyright (c) 1998,99 Kazuho Okui and Takashi Murai. * * Distributed unter the terms of the MIT License. + * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Daniel Furrer, assimil8or@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ @@ -60,7 +65,7 @@ static const pref_defaults kTermDefaults[] = { { PREF_ANSI_MAGENTA_COLOR, "115, 68, 123" }, { PREF_ANSI_CYAN_COLOR, " 6, 152, 154" }, { PREF_ANSI_WHITE_COLOR, "245, 245, 245" }, - + { PREF_ANSI_BLACK_HCOLOR, "128, 128, 128" }, { PREF_ANSI_RED_HCOLOR, "255, 0, 0" }, { PREF_ANSI_GREEN_HCOLOR, " 0, 255, 0" }, @@ -204,11 +209,12 @@ PrefHandler::SaveAsText(const char *path, const char *mimetype, fContainer.GetInfo(B_STRING_TYPE, i, (char**)&key, &type) == B_OK; #endif i++) { - int len = snprintf(buffer, sizeof(buffer), "\"%s\" , \"%s\"\n", key, getString(key)); + int len = snprintf(buffer, sizeof(buffer), "\"%s\" , \"%s\"\n", + key, getString(key)); file.Write(buffer, len); } - if (mimetype != NULL){ + if (mimetype != NULL) { BNodeInfo info(&file); info.SetType(mimetype); info.SetPreferredApp(signature); @@ -237,6 +243,7 @@ PrefHandler::getFloat(const char *key) return atof(value); } + #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "Terminal getString" diff --git a/src/apps/terminal/PrefHandler.h b/src/apps/terminal/PrefHandler.h index 466638cb6a..83c565dc45 100644 --- a/src/apps/terminal/PrefHandler.h +++ b/src/apps/terminal/PrefHandler.h @@ -1,10 +1,15 @@ /* - * Copyright (c) 2003-2006, Haiku, Inc. All Rights Reserved. + * Copyright (c) 2003-2013, Haiku, Inc. All Rights Reserved. * Copyright (c) 2004 Daniel Furrer * Copyright (c) 2003-4 Kian Duffy * Copyright (c) 1998,99 Kazuho Okui and Takashi Murai. * * Distributed unter the terms of the MIT License. + * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Daniel Furrer, assimil8or@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef PREF_HANDLER_H #define PREF_HANDLER_H diff --git a/src/apps/terminal/Shell.cpp b/src/apps/terminal/Shell.cpp index 2209f072d4..be93b97114 100644 --- a/src/apps/terminal/Shell.cpp +++ b/src/apps/terminal/Shell.cpp @@ -1,11 +1,15 @@ /* - * Copyright 2007-2010, Haiku, Inc. All rights reserved. + * Copyright 2007-2013, Haiku, Inc. All rights reserved. * Copyright (c) 2003-4 Kian Duffy * Copyright (c) 2004 Daniel Furrer * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * * Distributed under the terms of the MIT license. * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Daniel Furrer, assimil8or@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ @@ -71,7 +75,6 @@ // TODO: should extract from /etc/passwd instead??? const char *kDefaultShell = "/bin/sh"; const char *kTerminalType = "xterm-256color"; -//const char *kTerminalType = "xterm"; /* * Set environment variable. @@ -382,6 +385,7 @@ initialize_termios(struct termios &tio) tio.c_cc[VSUSP] = CSUSP; /* '^Z' */ } + #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "Terminal Shell" diff --git a/src/apps/terminal/TermApp.cpp b/src/apps/terminal/TermApp.cpp index b936d204ab..908edc0f43 100644 --- a/src/apps/terminal/TermApp.cpp +++ b/src/apps/terminal/TermApp.cpp @@ -1,9 +1,13 @@ /* - * Copyright 2001-2010, Haiku, Inc. All rights reserved. + * Copyright 2001-2013, Haiku, Inc. All rights reserved. * Copyright (c) 2003-2004 Kian Duffy * Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * * Distributed unter the terms of the MIT license. + * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ @@ -292,7 +296,6 @@ TermApp::_ChildCleanupThread(void* data) } - void TermApp::_Usage(char *name) { @@ -351,4 +354,3 @@ TermApp::_InitDefaultPalette() for (uint gray = 8; gray < 240; gray += 10) (*color++).set_to(gray, gray, gray); } - diff --git a/src/apps/terminal/TermApp.h b/src/apps/terminal/TermApp.h index 3fe12f1968..45fbd834b5 100644 --- a/src/apps/terminal/TermApp.h +++ b/src/apps/terminal/TermApp.h @@ -1,32 +1,13 @@ /* - * Copyright 2001-2010, Haiku. + * Copyright 2001-2013, Haiku. * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files or portions - * thereof (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice - * in the binary, as well as this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with - * the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + * Distributed under the terms of the MIT License. * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef TERM_APP_H #define TERM_APP_H diff --git a/src/apps/terminal/TermConst.h b/src/apps/terminal/TermConst.h index 34b57ed1ea..0471b1cc8e 100644 --- a/src/apps/terminal/TermConst.h +++ b/src/apps/terminal/TermConst.h @@ -1,32 +1,13 @@ /* - * Copyright 2001-2009, Haiku. + * Copyright 2001-2013, Haiku. * Copyright (c) 2003-4 Kian Duffy * Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files or portions - * thereof (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice - * in the binary, as well as this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with - * the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + * Distributed under the terms of the MIT License. * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef TERMCONST_H_INCLUDED #define TERMCONST_H_INCLUDED @@ -164,16 +145,8 @@ static const char* const PREF_WINDOW_TITLE = "Window title"; extern const char* const kTooTipSetTabTitlePlaceholders; extern const char* const kTooTipSetWindowTitlePlaceholders; -// Color type -enum { - TEXT_FOREGROUND_COLOR, - TEXT_BACKGROUND_COLOR, - SELECTION_FOREGROUND_COLOR, - SELECTION_BACKGROUND_COLOR -}; - -// Cursor shape +// Cursor style enum { BLOCK_CURSOR, UNDERLINE_CURSOR, @@ -189,12 +162,6 @@ static const int32 DEFAULT = -1; static const int HALF_WIDTH = 1; static const int FULL_WIDTH = 2; -// Scroll direction flag -enum{ - SCRUP, - SCRDOWN -}; - #define M_UTF8 -1 #define TAB_WIDTH 8 diff --git a/src/apps/terminal/TermParse.cpp b/src/apps/terminal/TermParse.cpp index 6f912ed2b8..202a720a7c 100644 --- a/src/apps/terminal/TermParse.cpp +++ b/src/apps/terminal/TermParse.cpp @@ -1,8 +1,12 @@ /* - * Copyright 2001-2010, Haiku, Inc. + * Copyright 2001-2013, Haiku, Inc. * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * Distributed under the terms of the MIT license. + * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ @@ -176,7 +180,7 @@ TermParse::_InitPtyReader() fReaderThread = spawn_thread(_ptyreader_thread, "PtyReader", B_NORMAL_PRIORITY, this); - if (fReaderThread < 0) { + if (fReaderThread < 0) { delete_sem(fReaderSem); fReaderSem = -1; delete_sem(fReaderLocker); @@ -485,40 +489,40 @@ TermParse::EscParse() /* "Special characters and line drawing" enabled by \E(0 */ switch (c) { case 'a': - fBuffer->InsertChar("\xE2\x96\x92",3); + fBuffer->InsertChar("\xE2\x96\x92", 3); break; case 'j': - fBuffer->InsertChar("\xE2\x94\x98",3); + fBuffer->InsertChar("\xE2\x94\x98", 3); break; case 'k': - fBuffer->InsertChar("\xE2\x94\x90",3); + fBuffer->InsertChar("\xE2\x94\x90", 3); break; case 'l': - fBuffer->InsertChar("\xE2\x94\x8C",3); + fBuffer->InsertChar("\xE2\x94\x8C", 3); break; case 'm': - fBuffer->InsertChar("\xE2\x94\x94",3); + fBuffer->InsertChar("\xE2\x94\x94", 3); break; case 'n': - fBuffer->InsertChar("\xE2\x94\xBC",3); + fBuffer->InsertChar("\xE2\x94\xBC", 3); break; case 'q': - fBuffer->InsertChar("\xE2\x94\x80",3); + fBuffer->InsertChar("\xE2\x94\x80", 3); break; case 't': - fBuffer->InsertChar("\xE2\x94\x9C",3); + fBuffer->InsertChar("\xE2\x94\x9C", 3); break; case 'u': - fBuffer->InsertChar("\xE2\x94\xA4",3); + fBuffer->InsertChar("\xE2\x94\xA4", 3); break; case 'v': - fBuffer->InsertChar("\xE2\x94\xB4",3); + fBuffer->InsertChar("\xE2\x94\xB4", 3); break; case 'w': - fBuffer->InsertChar("\xE2\x94\xAC",3); + fBuffer->InsertChar("\xE2\x94\xAC", 3); break; case 'x': - fBuffer->InsertChar("\xE2\x94\x82",3); + fBuffer->InsertChar("\xE2\x94\x82", 3); break; default: fBuffer->InsertChar((char)c); @@ -694,7 +698,7 @@ TermParse::EscParse() param[nparam++] = DEFAULT; break; - case CASE_CSI_SP: // ESC [N q + case CASE_CSI_SP: // ESC [N q // part of change cursor style DECSCUSR if (nparam < NPARAM) param[nparam++] = ' '; @@ -1136,14 +1140,13 @@ TermParse::EscParse() break; } default: - if (!isprint(params[i] & 0x7f)) { + if (!isprint(params[i] & 0x7f)) break; - } continue; } params[i] = '\0'; } - + if (isParsed) _ProcessOperatingSystemControls(params); @@ -1546,7 +1549,7 @@ TermParse::_ProcessOperatingSystemControls(uchar* params) case 104: // reset colors (0 - 255) { bool reset = (mode / 100) == 1; - + // colors can be in "idx1:name1;...;idxN:nameN;" sequence too! uint32 count = 0; char* p = strtok((char*)params, ";"); @@ -1558,16 +1561,14 @@ TermParse::_ProcessOperatingSystemControls(uchar* params) if (p == NULL) break; - if (gXColorsTable.LookUpColor(p, &colors[count]) == B_OK) { + if (gXColorsTable.LookUpColor(p, &colors[count]) == B_OK) count++; - } - } else { + } else count++; - } p = strtok(NULL, ";"); - } while(p != NULL && count < kTermColorCount); - + } while (p != NULL && count < kTermColorCount); + if (count > 0) { if (!reset) fBuffer->SetColors(indexes, colors, count); @@ -1588,13 +1589,13 @@ TermParse::_ProcessOperatingSystemControls(uchar* params) // dyna-colors are pos-sensitive - no chance to continue break; } - + indexes[count] = 10 + offset + count; count++; - p = strtok(NULL, ";"); - } while(p != NULL && (offset + count) < 10); - + + } while (p != NULL && (offset + count) < 10); + if (count > 0) { fBuffer->SetColors(indexes, colors, count, true); } @@ -1609,8 +1610,7 @@ TermParse::_ProcessOperatingSystemControls(uchar* params) } break; default: - printf("%d -> %s\n", mode, params); + // printf("%d -> %s\n", mode, params); break; } } - diff --git a/src/apps/terminal/TermParse.h b/src/apps/terminal/TermParse.h index 625457322a..35790d36ca 100644 --- a/src/apps/terminal/TermParse.h +++ b/src/apps/terminal/TermParse.h @@ -1,31 +1,13 @@ /* + * Copyright 2013, Haiku, Inc. All rights reserved. * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files or portions - * thereof (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice - * in the binary, as well as this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with - * the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + * Distributed under the terms of the MIT License. * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef TERMPARSE_H #define TERMPARSE_H diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index 771890dc26..0de284b7f1 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Haiku, Inc. + * Copyright 2001-2013, Haiku, Inc. * Copyright 2003-2004 Kian Duffy, myob@users.sourceforge.net * Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai. * All rights reserved. Distributed under the terms of the MIT license. @@ -10,6 +10,7 @@ * Y.Hayakawa, hida@sawada.riec.tohoku.ac.jp * Ingo Weinhold, ingo_weinhold@gmx.de * Clemens Zeidler, haiku@Clemens-Zeidler.de + * Siarzhuk Zharski, zharik@gmx.li */ @@ -332,7 +333,7 @@ TermView::_InitObject(const ShellParameters& shellParameters) fVisibleTextBuffer = new(std::nothrow) BasicTerminalBuffer; if (fVisibleTextBuffer == NULL) return B_NO_MEMORY; - + // TODO: Make the special word chars user-settable! fCharClassifier = new(std::nothrow) CharClassifier( kDefaultSpecialWordChars); @@ -356,7 +357,7 @@ TermView::_InitObject(const ShellParameters& shellParameters) // set the shell parameters' encoding ShellParameters modifiedShellParameters(shellParameters); - + const BCharacterSet* charset = BCharacterSetRoster::GetCharacterSetByConversionID(fEncoding); modifiedShellParameters.SetEncoding(charset ? charset->GetName() : "UTF-8"); @@ -653,7 +654,7 @@ TermView::SetTermColor(uint index, rgb_color color, bool dynamic) fTextBuffer->SetPaletteColor(index, color); return; } - + switch (index) { case 10: fTextForeColor = color; @@ -942,15 +943,12 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf, // color attribute int forecolor = IS_FORECOLOR(attr); int backcolor = IS_BACKCOLOR(attr); - + if (IS_FORESET(attr)) rgb_fore = fTextBuffer->PaletteColor(forecolor); if (IS_BACKSET(attr)) rgb_back = fTextBuffer->PaletteColor(backcolor); -// printf("DLP:[%03x %03x %03x]; [%03x %03x %03x];\n", -// rgb_fore.red, rgb_fore.green, rgb_fore.blue, rgb_back.red, rgb_back.green, rgb_back.blue); - // Selection check. if (cursor) { rgb_fore = fCursorForeColor; @@ -1040,7 +1038,6 @@ TermView::_DrawCursor() _DrawLinePart(fCursor.x * fFontWidth, (int32)rect.top, attr, buffer, width, selected, cursorVisible, this); } else { - if (selected) SetHighColor(fSelectBackColor); else if (cursorVisible ) @@ -1063,7 +1060,6 @@ TermView::_DrawCursor() FillRect(rect); } - } @@ -1624,19 +1620,19 @@ TermView::MessageReceived(BMessage *msg) #if 0 } else if (msg->FindData("RGBColor", B_RGB_COLOR_TYPE, (const void **)&color, &numBytes) == B_OK - && numBytes == sizeof(color)) { + && numBytes == sizeof(color)) { // TODO: handle color drop // maybe only on replicants ? return; #endif } else if (msg->FindData("text/plain", B_MIME_TYPE, - (const void **)&text, &numBytes) == B_OK) { + (const void **)&text, &numBytes) == B_OK) { _WritePTY(text, numBytes); return; } } - switch (msg->what){ + switch (msg->what) { case B_SIMPLE_DATA: case B_REFS_RECEIVED: { @@ -1853,11 +1849,9 @@ TermView::MessageReceived(BMessage *msg) int32 count = 0; if (msg->FindInt32("count", &count) != B_OK) break; - bool dynamic = false; if (msg->FindBool("dynamic", &dynamic) != B_OK) break; - for (int i = 0; i < count; i++) { uint8 index = 0; if (msg->FindUInt8("index", i, &index) != B_OK) @@ -1868,10 +1862,8 @@ TermView::MessageReceived(BMessage *msg) if (msg->FindData("color", B_RGB_COLOR_TYPE, i, (const void**)&color, &bytes) != B_OK) break; - SetTermColor(index, *color, dynamic); } - break; } case MSG_RESET_TERMINAL_COLORS: @@ -1879,11 +1871,9 @@ TermView::MessageReceived(BMessage *msg) int32 count = 0; if (msg->FindInt32("count", &count) != B_OK) break; - bool dynamic = false; if (msg->FindBool("dynamic", &dynamic) != B_OK) break; - for (int i = 0; i < count; i++) { uint8 index = 0; if (msg->FindUInt8("index", i, &index) != B_OK) @@ -1893,7 +1883,6 @@ TermView::MessageReceived(BMessage *msg) SetTermColor(index, TermApp::DefaultPalette()[index], dynamic); } - break; } case MSG_SET_CURSOR_STYLE: @@ -2455,7 +2444,7 @@ TermView::_SendMouseEvent(int32 buttons, int32 mode, int32 x, int32 y, char xtermButtons; if (buttons == B_PRIMARY_MOUSE_BUTTON) xtermButtons = 32 + 0; - else if (buttons == B_SECONDARY_MOUSE_BUTTON) + else if (buttons == B_SECONDARY_MOUSE_BUTTON) xtermButtons = 32 + 1; else if (buttons == B_TERTIARY_MOUSE_BUTTON) xtermButtons = 32 + 2; @@ -2494,8 +2483,8 @@ TermView::MouseDown(BPoint where) if (fReportAnyMouseEvent || fReportButtonMouseEvent || fReportNormalMouseEvent || fReportX10MouseEvent) { - TermPos clickPos = _ConvertToTerminal(where); - _SendMouseEvent(buttons, modifier, clickPos.x, clickPos.y, false); + TermPos clickPos = _ConvertToTerminal(where); + _SendMouseEvent(buttons, modifier, clickPos.x, clickPos.y, false); return; } @@ -2588,17 +2577,17 @@ TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) int32 modifier; Window()->CurrentMessage()->FindInt32("modifiers", &modifier); - TermPos clickPos = _ConvertToTerminal(where); + TermPos clickPos = _ConvertToTerminal(where); - if (fReportButtonMouseEvent) { - if (fPrevPos.x != clickPos.x || fPrevPos.y != clickPos.y) { - _SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y, + if (fReportButtonMouseEvent) { + if (fPrevPos.x != clickPos.x || fPrevPos.y != clickPos.y) { + _SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y, true); - } - fPrevPos = clickPos; - return; - } - _SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y, true); + } + fPrevPos = clickPos; + return; + } + _SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y, true); return; } @@ -2680,8 +2669,8 @@ TermView::MouseUp(BPoint where) if (fReportAnyMouseEvent || fReportButtonMouseEvent || fReportNormalMouseEvent) { - TermPos clickPos = _ConvertToTerminal(where); - _SendMouseEvent(0, 0, clickPos.x, clickPos.y, false); + TermPos clickPos = _ConvertToTerminal(where); + _SendMouseEvent(0, 0, clickPos.x, clickPos.y, false); } else { if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0 && (fMouseButtons & B_PRIMARY_MOUSE_BUTTON) != 0) { @@ -3206,7 +3195,6 @@ TermView::_HandleInputMethodLocationRequest() } - void TermView::_CancelInputMethod() { @@ -3267,16 +3255,16 @@ TermView::MakeDebugSnapshots() { BAutolock _(fTextBuffer); time_t timeStamp = time(NULL); - fTextBuffer->MakeLinesSnapshots(timeStamp, ".TextBuffer.log"); - fVisibleTextBuffer->MakeLinesSnapshots(timeStamp, ".VisualTextBuffer.log"); + fTextBuffer->MakeLinesSnapshots(timeStamp, ".TextBuffer.dump"); + fVisibleTextBuffer->MakeLinesSnapshots(timeStamp, ".VisualTextBuffer.dump"); } void -TermView::RestartDebugCapture() +TermView::StartStopDebugCapture() { BAutolock _(fTextBuffer); - fTextBuffer->RestartDebugCapture(); + fTextBuffer->StartStopDebugCapture(); } #endif diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h index ca90d987b4..b3cbaa8f8e 100644 --- a/src/apps/terminal/TermView.h +++ b/src/apps/terminal/TermView.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Haiku, Inc. + * Copyright 2001-2013, Haiku, Inc. * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * @@ -8,6 +8,7 @@ * Stefano Ceccherini, stefano.ceccherini@gmail.com * Kian Duffy, myob@users.sourceforge.net * Ingo Weinhold, ingo_weinhold@gmx.de + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef TERMVIEW_H #define TERMVIEW_H @@ -91,7 +92,7 @@ public: void SetMouseClipboard(BClipboard *); void MakeDebugSnapshots(); - void RestartDebugCapture(); + void StartStopDebugCapture(); // edit functions void Copy(BClipboard* clipboard); diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 1e33dfa4fb..3703ec21ce 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -1,10 +1,15 @@ /* - * Copyright 2007-2010, Haiku, Inc. All rights reserved. + * Copyright 2007-2013, Haiku, Inc. All rights reserved. * Copyright (c) 2004 Daniel Furrer * Copyright (c) 2003-2004 Kian Duffy * Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * * Distributed under the terms of the MIT license. + * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Daniel Furrer, assimil8or@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ #include "TermWindow.h" @@ -386,7 +391,7 @@ void TermWindow::MenusBeginning() { TermView* view = _ActiveTermView(); - + // Syncronize Encode Menu Pop-up menu and Preference. const BCharacterSet* charset = BCharacterSetRoster::GetCharacterSetByConversionID(view->Encoding()); @@ -473,7 +478,7 @@ TermWindow::_SetupMenu() .AddItem(B_TRANSLATE("New tab"), kNewTab, 'T') .AddSeparator() .AddItem(B_TRANSLATE("Page setup" B_UTF8_ELLIPSIS), MENU_PAGE_SETUP) - .AddItem(B_TRANSLATE("Print"), MENU_PRINT,'P') + .AddItem(B_TRANSLATE("Print"), MENU_PRINT, 'P') .AddSeparator() .AddItem(B_TRANSLATE("Close window"), B_QUIT_REQUESTED, 'W', B_SHIFT_KEY) @@ -483,13 +488,13 @@ TermWindow::_SetupMenu() // Edit .AddMenu(B_TRANSLATE("Edit")) - .AddItem(B_TRANSLATE("Copy"), B_COPY,'C') - .AddItem(B_TRANSLATE("Paste"), B_PASTE,'V') + .AddItem(B_TRANSLATE("Copy"), B_COPY, 'C') + .AddItem(B_TRANSLATE("Paste"), B_PASTE, 'V') .AddSeparator() .AddItem(B_TRANSLATE("Select all"), B_SELECT_ALL, 'A') .AddItem(B_TRANSLATE("Clear all"), MENU_CLEAR_ALL, 'L') .AddSeparator() - .AddItem(B_TRANSLATE("Find" B_UTF8_ELLIPSIS), MENU_FIND_STRING,'F') + .AddItem(B_TRANSLATE("Find" B_UTF8_ELLIPSIS), MENU_FIND_STRING, 'F') .AddItem(B_TRANSLATE("Find previous"), MENU_FIND_PREVIOUS, 'G', B_SHIFT_KEY) .GetItem(fFindPreviousMenuItem) @@ -671,7 +676,7 @@ TermWindow::MessageReceived(BMessage *message) break; case SHORTCUT_DEBUG_CAPTURE: - _ActiveTermView()->RestartDebugCapture(); + _ActiveTermView()->StartStopDebugCapture(); break; #endif @@ -710,8 +715,7 @@ TermWindow::MessageReceived(BMessage *message) case MENU_PREF_OPEN: if (!fPrefWindow) { fPrefWindow = new PrefWindow(this); - } - else + } else fPrefWindow->Activate(); break; @@ -728,8 +732,7 @@ TermWindow::MessageReceived(BMessage *message) if (!fFindPanel) { fFindPanel = new FindWindow(this, fFindString, fFindSelection, fMatchWord, fMatchCase, fForwardSearch); - } - else + } else fFindPanel->Activate(); break; @@ -760,7 +763,8 @@ TermWindow::MessageReceived(BMessage *message) message->FindBool("forwardsearch", &fForwardSearch); message->FindBool("matchcase", &fMatchCase); message->FindBool("matchword", &fMatchWord); - findresult = _ActiveTermView()->Find(fFindString, fForwardSearch, fMatchCase, fMatchWord); + findresult = _ActiveTermView()->Find(fFindString, fForwardSearch, + fMatchCase, fMatchWord); if (!findresult) { BAlert* alert = new BAlert(B_TRANSLATE("Find failed"), @@ -899,7 +903,7 @@ TermWindow::MessageReceived(BMessage *message) fTabView->ResizeBy(0, -mbHeight); fTabView->MoveBy(0, mbHeight); SetLook(fSavedLook); - fSavedFrame = BRect(0,0,-1,-1); + fSavedFrame = BRect(0, 0, -1, -1); SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE)); fFullScreen = false; } @@ -922,7 +926,8 @@ TermWindow::MessageReceived(BMessage *message) { BPath path; if (PrefHandler::GetDefaultPath(path) == B_OK) - PrefHandler::Default()->SaveAsText(path.Path(), PREFFILE_MIMETYPE); + PrefHandler::Default()->SaveAsText(path.Path(), + PREFFILE_MIMETYPE); break; } case MENU_PAGE_SETUP: @@ -1221,7 +1226,8 @@ TermWindow::_AddTab(Arguments* args, const BString& currentDirectory) BScrollView* scrollView = new TermScrollView("scrollView", containerView, view, fSessions.IsEmpty()); if (!fFullScreen) - scrollView->ScrollBar(B_VERTICAL)->ResizeBy(0, -(B_H_SCROLL_BAR_HEIGHT - 1)); + scrollView->ScrollBar(B_VERTICAL) + ->ResizeBy(0, -(B_H_SCROLL_BAR_HEIGHT - 1)); if (fSessions.IsEmpty()) fTabView->SetScrollView(scrollView); @@ -1964,7 +1970,7 @@ TermWindow::_NewSessionIndex() bool used = false; for (int32 i = 0; - Session* session = _SessionAt(i); i++) { + Session* session = _SessionAt(i); i++) { if (id == session->index) { used = true; break; diff --git a/src/apps/terminal/TerminalBuffer.cpp b/src/apps/terminal/TerminalBuffer.cpp index e6dae771fd..6910f28c51 100644 --- a/src/apps/terminal/TerminalBuffer.cpp +++ b/src/apps/terminal/TerminalBuffer.cpp @@ -1,6 +1,11 @@ /* + * Copyright 2013, Haiku, Inc. All rights reserved. * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold, ingo_weinhold@gmx.de + * Siarzhuk Zharski, zharik@gmx.li */ #include "TerminalBuffer.h" @@ -242,7 +247,7 @@ TerminalBuffer::GuessPaletteColor(int red, int green, int blue) { int distance = 255 * 100; int index = -1; - for (int i = 0; i < kTermColorCount && distance > 0; i++) { + for (uint32 i = 0; i < kTermColorCount && distance > 0; i++) { rgb_color color = fColorsPalette[i]; int r = 30 * abs(color.red - red); int g = 59 * abs(color.green - green); @@ -254,7 +259,7 @@ TerminalBuffer::GuessPaletteColor(int red, int green, int blue) } } - return min_c(index, kTermColorCount - 1); + return min_c(index, int(kTermColorCount - 1)); } diff --git a/src/apps/terminal/TerminalBuffer.h b/src/apps/terminal/TerminalBuffer.h index 56fd38a111..f1c7c3c06a 100644 --- a/src/apps/terminal/TerminalBuffer.h +++ b/src/apps/terminal/TerminalBuffer.h @@ -1,6 +1,11 @@ /* + * Copyright 2013, Haiku, Inc. All rights reserved. * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold, ingo_weinhold@gmx.de + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef TERMINAL_BUFFER_H #define TERMINAL_BUFFER_H diff --git a/src/apps/terminal/TerminalLine.h b/src/apps/terminal/TerminalLine.h index 5f2e4a7d9c..044cce7d99 100644 --- a/src/apps/terminal/TerminalLine.h +++ b/src/apps/terminal/TerminalLine.h @@ -1,6 +1,11 @@ /* + * Copyright 2013, Haiku, Inc. All rights reserved. * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold, ingo_weinhold@gmx.de + * Siarzhuk Zharski, zharik@gmx.li */ #ifndef TERMINAL_LINE_H #define TERMINAL_LINE_H diff --git a/src/apps/terminal/VTPrsTbl.c b/src/apps/terminal/VTPrsTbl.c index 6d09b304d5..ab4d85ea12 100644 --- a/src/apps/terminal/VTPrsTbl.c +++ b/src/apps/terminal/VTPrsTbl.c @@ -2,30 +2,11 @@ * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files or portions - * thereof (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice - * in the binary, as well as this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with - * the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + * Distributed under the terms of the MIT License. * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */ #include "VTparse.h" @@ -115,7 +96,7 @@ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, -CASE_PRINT, +CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, @@ -440,7 +421,7 @@ CASE_PRINT_CS96, CASE_PRINT_CS96, CASE_PRINT_CS96, CASE_PRINT_CS96, -CASE_PRINT_CS96, +CASE_PRINT_CS96, /* @ A B C */ CASE_PRINT_CS96, CASE_PRINT_CS96, @@ -1090,7 +1071,7 @@ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, -CASE_PRINT, +CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, @@ -3028,7 +3009,7 @@ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ -CASE_GROUND_STATE, +CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_IGNORE_ESC, @@ -4805,7 +4786,7 @@ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, -CASE_PRINT, +CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, @@ -5131,7 +5112,7 @@ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, -CASE_PRINT, +CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, diff --git a/src/apps/terminal/VTparse.h b/src/apps/terminal/VTparse.h index 0fefe3bd4c..e2f6da19a6 100644 --- a/src/apps/terminal/VTparse.h +++ b/src/apps/terminal/VTparse.h @@ -1,31 +1,12 @@ /* * Copyright (c) 2003-4 Kian Duffy - * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. + * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files or portions - * thereof (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice - * in the binary, as well as this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with - * the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + * Distributed under the terms of the MIT License. * + * Authors: + * Kian Duffy, myob@users.sourceforge.net + * Siarzhuk Zharski, zharik@gmx.li */