Style and header updates
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13939 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+33
-103
@@ -1,65 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2001-2005, Haiku, Inc.
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Authors:
|
||||||
* a copy of this software and associated documentation files or portions
|
* Kian Duffy <[email protected]>
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CurPos.h"
|
#include "CurPos.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
*
|
|
||||||
* Constructor and Destructor
|
|
||||||
*
|
|
||||||
************************************************************************/
|
|
||||||
|
|
||||||
CurPos::CurPos()
|
CurPos::CurPos()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CurPos::CurPos(int32 X, int32 Y)
|
CurPos::CurPos(int32 X, int32 Y)
|
||||||
{
|
{
|
||||||
x = X;
|
x = X;
|
||||||
y = Y;
|
y = Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CurPos::CurPos(const CurPos& cp)
|
CurPos::CurPos(const CurPos& cp)
|
||||||
{
|
{
|
||||||
x = cp.x;
|
x = cp.x;
|
||||||
y = cp.y;
|
y = cp.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator =
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
CurPos &
|
CurPos &
|
||||||
CurPos::operator=(const CurPos& from)
|
CurPos::operator=(const CurPos& from)
|
||||||
{
|
{
|
||||||
@@ -68,10 +33,6 @@ CurPos::operator=(const CurPos& from)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Set Function.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
CurPos::Set(int32 X, int32 Y)
|
CurPos::Set(int32 X, int32 Y)
|
||||||
{
|
{
|
||||||
@@ -79,105 +40,74 @@ CurPos::Set(int32 X, int32 Y)
|
|||||||
y = Y;
|
y = Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator !=
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool
|
bool
|
||||||
CurPos::operator!=(const CurPos& from) const
|
CurPos::operator!=(const CurPos& from) const
|
||||||
{
|
{
|
||||||
return ((x != from.x) || (y != from.y));
|
return ((x != from.x) || (y != from.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator ==
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool
|
bool
|
||||||
CurPos::operator==(const CurPos& from) const
|
CurPos::operator==(const CurPos& from) const
|
||||||
{
|
{
|
||||||
return ((x == from.x) && (y == from.y));
|
return ((x == from.x) && (y == from.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator +
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
CurPos
|
CurPos
|
||||||
CurPos::operator+(const CurPos& from) const
|
CurPos::operator+(const CurPos& from) const
|
||||||
{
|
{
|
||||||
return CurPos(x + from.x, y + from.y);
|
return CurPos(x + from.x, y + from.y);
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator -
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
CurPos
|
CurPos
|
||||||
CurPos::operator- (const CurPos& from) const
|
CurPos::operator- (const CurPos& from) const
|
||||||
{
|
{
|
||||||
return CurPos(x - from.x, y - from.y);
|
return CurPos(x - from.x, y - from.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator >
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool
|
bool
|
||||||
CurPos::operator> (const CurPos& from) const
|
CurPos::operator> (const CurPos& from) const
|
||||||
{
|
{
|
||||||
if (y > from.y) {
|
if (y > from.y)
|
||||||
return true;
|
return true;
|
||||||
} else if (y == from.y && x > from.x) {
|
else
|
||||||
return true;
|
if (y == from.y && x > from.x)
|
||||||
}
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator >=
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool
|
bool
|
||||||
CurPos::operator>= (const CurPos& from) const
|
CurPos::operator>= (const CurPos& from) const
|
||||||
{
|
{
|
||||||
if (y > from.y) {
|
if (y > from.y)
|
||||||
return true;
|
return true;
|
||||||
} else if (y == from.y && x >= from.x) {
|
else
|
||||||
return true;
|
if (y == from.y && x >= from.x)
|
||||||
}
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator <
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool
|
bool
|
||||||
CurPos::operator< (const CurPos& from) const
|
CurPos::operator< (const CurPos& from) const
|
||||||
{
|
{
|
||||||
if (y < from.y) {
|
if (y < from.y)
|
||||||
return true;
|
return true;
|
||||||
} else if (y == from.y && x < from.x) {
|
else
|
||||||
return true;
|
if (y == from.y && x < from.x)
|
||||||
}
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CurPos
|
|
||||||
// Operator <=
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool
|
bool
|
||||||
CurPos::operator<= (const CurPos& from) const
|
CurPos::operator<= (const CurPos& from) const
|
||||||
{
|
{
|
||||||
if (y < from.y) {
|
if (y < from.y)
|
||||||
return true;
|
return true;
|
||||||
} else if (y == from.y && x <= from.x) {
|
else
|
||||||
return true;
|
if (y == from.y && x <= from.x)
|
||||||
}
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-45
@@ -1,33 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2001-2005, Haiku, Inc.
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Authors:
|
||||||
* a copy of this software and associated documentation files or portions
|
* Kian Duffy <[email protected]>
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CURPOS_H_INCLUDED
|
#ifndef CURPOS_H_INCLUDED
|
||||||
#define CURPOS_H_INCLUDED
|
#define CURPOS_H_INCLUDED
|
||||||
|
|
||||||
@@ -35,26 +14,25 @@
|
|||||||
|
|
||||||
class CurPos
|
class CurPos
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int32 x;
|
CurPos();
|
||||||
int32 y;
|
CurPos(int32 X, int32 Y);
|
||||||
|
CurPos(const CurPos& cp);
|
||||||
CurPos();
|
|
||||||
CurPos(int32 X, int32 Y);
|
void Set(int32 X, int32 Y);
|
||||||
CurPos(const CurPos& cp);
|
|
||||||
|
CurPos &operator= (const CurPos &from);
|
||||||
void Set(int32 X, int32 Y);
|
CurPos operator+ (const CurPos&) const;
|
||||||
|
CurPos operator- (const CurPos&) const;
|
||||||
CurPos &operator= (const CurPos &from);
|
bool operator!= (const CurPos&) const;
|
||||||
CurPos operator+ (const CurPos&) const;
|
bool operator== (const CurPos&) const;
|
||||||
CurPos operator- (const CurPos&) const;
|
bool operator> (const CurPos&) const;
|
||||||
bool operator!= (const CurPos&) const;
|
bool operator>= (const CurPos&) const;
|
||||||
bool operator== (const CurPos&) const;
|
bool operator< (const CurPos&) const;
|
||||||
bool operator> (const CurPos&) const;
|
bool operator<= (const CurPos&) const;
|
||||||
bool operator>= (const CurPos&) const;
|
|
||||||
bool operator< (const CurPos&) const;
|
|
||||||
bool operator<= (const CurPos&) const;
|
|
||||||
|
|
||||||
|
int32 x;
|
||||||
|
int32 y;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CURPOS_H_INCLUDED */
|
#endif
|
||||||
|
|||||||
@@ -1,33 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2001-2005, Haiku, Inc.
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Authors:
|
||||||
* a copy of this software and associated documentation files or portions
|
* Kian Duffy <[email protected]>
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
@@ -44,7 +23,6 @@ extern PrefHandler *gTermPref;
|
|||||||
|
|
||||||
//#define LOCALE_FILE_DIR PREF_FOLDER"menu/"
|
//#define LOCALE_FILE_DIR PREF_FOLDER"menu/"
|
||||||
|
|
||||||
|
|
||||||
BPopUpMenu *
|
BPopUpMenu *
|
||||||
MakeMenu(ulong msg, const char **items, const char *defaultItemName)
|
MakeMenu(ulong msg, const char **items, const char *defaultItemName)
|
||||||
{
|
{
|
||||||
@@ -62,7 +40,6 @@ MakeMenu(ulong msg, const char **items, const char *defaultItemName)
|
|||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
longname2op(const char *longname)
|
longname2op(const char *longname)
|
||||||
{
|
{
|
||||||
@@ -78,14 +55,12 @@ longname2op(const char *longname)
|
|||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
op2longname(int op)
|
op2longname(int op)
|
||||||
{
|
{
|
||||||
return encoding_table[op].name;
|
return encoding_table[op].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MakeEncodingMenu(BMenu *eMenu, int coding, bool flag)
|
MakeEncodingMenu(BMenu *eMenu, int coding, bool flag)
|
||||||
{
|
{
|
||||||
@@ -98,22 +73,21 @@ MakeEncodingMenu(BMenu *eMenu, int coding, bool flag)
|
|||||||
eMenu->AddItem(new BMenuItem(e->name, msg, e->shortcut));
|
eMenu->AddItem(new BMenuItem(e->name, msg, e->shortcut));
|
||||||
else
|
else
|
||||||
eMenu->AddItem(new BMenuItem(e->name, msg));
|
eMenu->AddItem(new BMenuItem(e->name, msg));
|
||||||
|
|
||||||
if (i == coding)
|
if (i == coding)
|
||||||
eMenu->ItemAt(i)->SetMarked(true);
|
eMenu->ItemAt(i)->SetMarked(true);
|
||||||
|
|
||||||
e++;
|
e++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LoadLocaleFile(PrefHandler *pref)
|
LoadLocaleFile(PrefHandler *pref)
|
||||||
{
|
{
|
||||||
char name[B_PATH_NAME_LENGTH];
|
char name[B_PATH_NAME_LENGTH];
|
||||||
const char *locale;
|
const char *locale;
|
||||||
|
|
||||||
locale = gTermPref->getString(PREF_GUI_LANGUAGE);
|
locale = gTermPref->getString(PREF_GUI_LANGUAGE);
|
||||||
// TODO: this effectively disables any locale support - which is okay for now
|
// TODO: this effectively disables any locale support - which is okay for now
|
||||||
sprintf(name, "%s%s", /*LOCALE_FILE_DIR*/"", locale);
|
sprintf(name, "%s%s", /*LOCALE_FILE_DIR*/"", locale);
|
||||||
@@ -121,4 +95,3 @@ LoadLocaleFile(PrefHandler *pref)
|
|||||||
//if (pref->OpenText(name) < B_OK)
|
//if (pref->OpenText(name) < B_OK)
|
||||||
// pref->OpenText(LOCALE_FILE_DEFAULT);
|
// pref->OpenText(LOCALE_FILE_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2001-2005, Haiku, Inc.
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Authors:
|
||||||
* a copy of this software and associated documentation files or portions
|
* Kian Duffy <[email protected]>
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENUUTIL_H_INCLUDED
|
#ifndef MENUUTIL_H_INCLUDED
|
||||||
#define MENUUTIL_H_INCLUDED
|
#define MENUUTIL_H_INCLUDED
|
||||||
|
|
||||||
@@ -41,16 +20,15 @@ class BPopUpMenu;
|
|||||||
class BMenu;
|
class BMenu;
|
||||||
class PrefHandler;
|
class PrefHandler;
|
||||||
|
|
||||||
BPopUpMenu * MakeMenu(ulong msg, const char **items,
|
BPopUpMenu * MakeMenu(ulong msg, const char **items,
|
||||||
const char *defaultItemName);
|
const char *defaultItemName);
|
||||||
|
int longname2op(const char *longname);
|
||||||
int longname2op(const char *longname);
|
const char * op2longname(int op);
|
||||||
const char * op2longname(int op);
|
void MakeEncodingMenu(BMenu *eMenu, int coding, bool flag);
|
||||||
void MakeEncodingMenu(BMenu *eMenu, int coding, bool flag);
|
void LoadLocaleFile (PrefHandler *);
|
||||||
void LoadLocaleFile (PrefHandler *);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //MENUUTIL_H_INCLUDED
|
#endif
|
||||||
|
|||||||
@@ -1,82 +1,36 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2001-2005, Haiku, Inc.
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Authors:
|
||||||
* a copy of this software and associated documentation files or portions
|
* Kian Duffy <[email protected]>
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TermBaseView.h"
|
#include "TermBaseView.h"
|
||||||
#include "TermView.h"
|
#include "TermView.h"
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
*
|
|
||||||
* CONSTRUCTOR and DESTRUCTOR
|
|
||||||
*
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TermBaseView ()
|
|
||||||
// Constructor.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
TermBaseView::TermBaseView (BRect frame, TermView *inTermView)
|
TermBaseView::TermBaseView (BRect frame, TermView *inTermView)
|
||||||
:BView (frame, "baseview", B_FOLLOW_ALL_SIDES,
|
:BView(frame, "baseview", B_FOLLOW_ALL_SIDES,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS)
|
B_WILL_DRAW | B_FRAME_EVENTS)
|
||||||
{
|
{
|
||||||
|
fTermView = inTermView;
|
||||||
fTermView = inTermView;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// ~TermBaseView ()
|
|
||||||
// Destructor.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
TermBaseView::~TermBaseView ()
|
TermBaseView::~TermBaseView ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* PUBLIC MEMBER FUNCTIONS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// FrameResized (float, float)
|
|
||||||
// Dispatch frame resize event.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBaseView::FrameResized (float width, float height)
|
TermBaseView::FrameResized (float width, float height)
|
||||||
{
|
{
|
||||||
int font_width, font_height;
|
int font_width, font_height;
|
||||||
int cols, rows;
|
int cols, rows;
|
||||||
|
|
||||||
fTermView->GetFontInfo (&font_width, &font_height);
|
fTermView->GetFontInfo (&font_width, &font_height);
|
||||||
|
|
||||||
cols = (int)(width - VIEW_OFFSET * 2) / font_width;
|
cols = (int)(width - VIEW_OFFSET * 2) / font_width;
|
||||||
rows = (int)(height - VIEW_OFFSET * 2)/ font_height;
|
rows = (int)(height - VIEW_OFFSET * 2)/ font_height;
|
||||||
|
|
||||||
fTermView->ResizeTo (cols * font_width - 1, rows * font_height - 1);
|
fTermView->ResizeTo (cols * font_width - 1, rows * font_height - 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+332
-462
@@ -1,31 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2001-2005, Haiku, Inc.
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Authors:
|
||||||
* a copy of this software and associated documentation files or portions
|
* Kian Duffy <[email protected]>
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@@ -69,7 +49,7 @@ c. 2byte status buffer.
|
|||||||
**Language environment. (Not impliment)
|
**Language environment. (Not impliment)
|
||||||
|
|
||||||
--- half width character set ---
|
--- half width character set ---
|
||||||
0 ... Wesern (Latin1 / ISO-8859-1, MacRoman)
|
0 ... Western (Latin1 / ISO-8859-1, MacRoman)
|
||||||
1 ... Central European(Latin2 / ISO-8859-2)
|
1 ... Central European(Latin2 / ISO-8859-2)
|
||||||
2 ... Turkish (Latin3 / ISO-8859-3)
|
2 ... Turkish (Latin3 / ISO-8859-3)
|
||||||
3 ... Baltic (Latin4 / ISO-8859-4)
|
3 ... Baltic (Latin4 / ISO-8859-4)
|
||||||
@@ -85,7 +65,7 @@ c. 2byte status buffer.
|
|||||||
--- Universal character set ---
|
--- Universal character set ---
|
||||||
10 ... Unicode (UTF8)
|
10 ... Unicode (UTF8)
|
||||||
|
|
||||||
* Varriables is set CodeConv class.
|
* Variables is set CodeConv class.
|
||||||
* Unicode character width sets CodeConv::UTF8FontWidth member.
|
* Unicode character width sets CodeConv::UTF8FontWidth member.
|
||||||
|
|
||||||
JIS X 0201 (half width kana ideograph) character use 1 column,
|
JIS X 0201 (half width kana ideograph) character use 1 column,
|
||||||
@@ -109,539 +89,429 @@ but it font is full width font on preference panel.
|
|||||||
extern PrefHandler *gTermPref;
|
extern PrefHandler *gTermPref;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// TermBuffer class
|
|
||||||
// Constructor and Destructor.
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
TermBuffer::TermBuffer(int rows, int cols)
|
TermBuffer::TermBuffer(int rows, int cols)
|
||||||
{
|
{
|
||||||
mColSize = MAX_COLS;
|
mColSize = MAX_COLS;
|
||||||
mNowColSize = cols;
|
mNowColSize = cols;
|
||||||
mRowSize = rows;
|
mRowSize = rows;
|
||||||
|
|
||||||
mRowOffset = 0;
|
mRowOffset = 0;
|
||||||
|
|
||||||
//buffer_size = ARRAY_SIZE;
|
//buffer_size = ARRAY_SIZE;
|
||||||
buffer_size = gTermPref->getInt32 (PREF_HISTORY_SIZE);
|
buffer_size = gTermPref->getInt32 (PREF_HISTORY_SIZE);
|
||||||
|
|
||||||
/* Allocate buffer */
|
// Allocate buffer
|
||||||
mBase = (term_buffer**) malloc (sizeof (term_buffer*) * buffer_size);
|
mBase = (term_buffer**) malloc (sizeof (term_buffer*) * buffer_size);
|
||||||
|
|
||||||
for(int i = 0; i < buffer_size; i++){
|
for(int i = 0; i < buffer_size; i++)
|
||||||
mBase[i] = (term_buffer *) calloc (mColSize + 1, sizeof (term_buffer));
|
mBase[i] = (term_buffer *) calloc (mColSize + 1, sizeof (term_buffer));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TermBuffer Destructer.
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
TermBuffer::~TermBuffer()
|
TermBuffer::~TermBuffer()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < buffer_size; i++){
|
for(int i = 0; i < buffer_size; i++)
|
||||||
free (mBase[i]);
|
free (mBase[i]);
|
||||||
}
|
|
||||||
|
|
||||||
free(mBase);
|
free(mBase);
|
||||||
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// int GetChar (row, col, *buf, attr)
|
// Gets a character from TermBuffer
|
||||||
// Get chracter from TermBuffer.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
/* This function moved to header file for effeciency */
|
|
||||||
int
|
int
|
||||||
TermBuffer::GetChar (int row, int col, uchar *buf, ushort *attr)
|
TermBuffer::GetChar (int row, int col, uchar *buf, ushort *attr)
|
||||||
{
|
{
|
||||||
term_buffer *ptr;
|
term_buffer *ptr;
|
||||||
|
|
||||||
ptr = (mBase[row % buffer_size] + col);
|
|
||||||
|
|
||||||
if (ptr->status == A_CHAR)
|
|
||||||
memcpy (buf, (char *)(ptr->code), 4);
|
|
||||||
|
|
||||||
*attr = ptr->attr;
|
|
||||||
|
|
||||||
return ptr->status;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// int GetString (row, col, *buf, attr)
|
|
||||||
// Get String (length = num) from given position.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
int
|
|
||||||
TermBuffer::GetString (int row, int col, int num,
|
|
||||||
uchar *buf, ushort *attr)
|
|
||||||
{
|
|
||||||
int count = 0, all_count = 0;
|
|
||||||
term_buffer *ptr;
|
|
||||||
|
|
||||||
ptr = (mBase[row % buffer_size]);
|
|
||||||
ptr += col;
|
|
||||||
*attr = ptr->attr;
|
|
||||||
|
|
||||||
if (ptr->status == NO_CHAR) {
|
|
||||||
/*
|
|
||||||
* Buffer is empty and No selected by mouse.
|
|
||||||
*/
|
|
||||||
do {
|
|
||||||
if (col >= mNowColSize) return -1;
|
|
||||||
|
|
||||||
col++;
|
|
||||||
ptr++;
|
|
||||||
count--;
|
|
||||||
if (ptr->status == A_CHAR)
|
|
||||||
return count;
|
|
||||||
|
|
||||||
if (mSelStart.y == row) {
|
|
||||||
if (col == mSelStart.x)
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
if (mSelEnd.y == row) {
|
|
||||||
if (col - 1 == mSelEnd.x)
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ptr = (mBase[row % buffer_size] + col);
|
||||||
}while (col <= num);
|
|
||||||
return count;
|
if (ptr->status == A_CHAR)
|
||||||
}
|
memcpy (buf, (char *)(ptr->code), 4);
|
||||||
else if (IS_WIDTH(ptr->attr)) {
|
|
||||||
memcpy (buf, (char *)ptr->code, 4);
|
*attr = ptr->attr;
|
||||||
return 2;
|
|
||||||
}
|
return ptr->status;
|
||||||
|
|
||||||
while (col <= num) {
|
|
||||||
memcpy (buf, ptr->code, 4);
|
|
||||||
all_count++;
|
|
||||||
|
|
||||||
if (*buf == 0) {
|
|
||||||
*buf = ' ';
|
|
||||||
*(buf + 1) = '\0';
|
|
||||||
}
|
|
||||||
if (ptr->attr != (ptr + 1)->attr){
|
|
||||||
return all_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = (uchar *)index ((char *)buf, 0x00);
|
|
||||||
ptr++;
|
|
||||||
col++;
|
|
||||||
|
|
||||||
if (mSelStart.y == row) {
|
|
||||||
if (col == mSelStart.x)
|
|
||||||
return all_count;
|
|
||||||
}
|
|
||||||
if (mSelEnd.y == row) {
|
|
||||||
if (col - 1 == mSelEnd.x)
|
|
||||||
return all_count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return all_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Get a string (length = num) from given position.
|
||||||
// void WriteChar (const CurPos &, const uchar *, ushort)
|
int
|
||||||
// Write character at cursor point.
|
TermBuffer::GetString (int row, int col, int num, uchar *buf,
|
||||||
////////////////////////////////////////////////////////////////////////////
|
ushort *attr)
|
||||||
|
{
|
||||||
|
int count = 0, all_count = 0;
|
||||||
|
term_buffer *ptr;
|
||||||
|
|
||||||
|
ptr = (mBase[row % buffer_size]);
|
||||||
|
ptr += col;
|
||||||
|
*attr = ptr->attr;
|
||||||
|
|
||||||
|
if (ptr->status == NO_CHAR) {
|
||||||
|
|
||||||
|
// Buffer is empty and No selected by mouse.
|
||||||
|
do {
|
||||||
|
if (col >= mNowColSize)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
col++;
|
||||||
|
ptr++;
|
||||||
|
count--;
|
||||||
|
if (ptr->status == A_CHAR)
|
||||||
|
return count;
|
||||||
|
|
||||||
|
if (mSelStart.y == row) {
|
||||||
|
if (col == mSelStart.x)
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSelEnd.y == row) {
|
||||||
|
if (col - 1 == mSelEnd.x)
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}while (col <= num);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
else if (IS_WIDTH(ptr->attr)) {
|
||||||
|
memcpy (buf, (char *)ptr->code, 4);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (col <= num) {
|
||||||
|
memcpy (buf, ptr->code, 4);
|
||||||
|
all_count++;
|
||||||
|
|
||||||
|
if (*buf == 0) {
|
||||||
|
*buf = ' ';
|
||||||
|
*(buf + 1) = '\0';
|
||||||
|
}
|
||||||
|
if (ptr->attr != (ptr + 1)->attr)
|
||||||
|
return all_count;
|
||||||
|
|
||||||
|
buf = (uchar *)index ((char *)buf, 0x00);
|
||||||
|
ptr++;
|
||||||
|
col++;
|
||||||
|
|
||||||
|
if (mSelStart.y == row) {
|
||||||
|
if (col == mSelStart.x)
|
||||||
|
return all_count;
|
||||||
|
}
|
||||||
|
if (mSelEnd.y == row) {
|
||||||
|
if (col - 1 == mSelEnd.x)
|
||||||
|
return all_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write a character at the cursor point.
|
||||||
void
|
void
|
||||||
TermBuffer::WriteChar (const CurPos &pos, const uchar *u, ushort attr)
|
TermBuffer::WriteChar (const CurPos &pos, const uchar *u, ushort attr)
|
||||||
{
|
{
|
||||||
term_buffer *ptr;
|
term_buffer *ptr;
|
||||||
|
|
||||||
const int row = pos.y;
|
const int row = pos.y;
|
||||||
const int col = pos.x;
|
const int col = pos.x;
|
||||||
|
|
||||||
ptr = (mBase[ROW(row)] + col);
|
ptr = (mBase[ROW(row)] + col);
|
||||||
memcpy ((char *)ptr->code, u, 4);
|
memcpy ((char *)ptr->code, u, 4);
|
||||||
if (IS_WIDTH(attr))
|
|
||||||
(ptr + 1)->status = IN_STRING;
|
if (IS_WIDTH(attr))
|
||||||
|
(ptr + 1)->status = IN_STRING;
|
||||||
ptr->status = A_CHAR;
|
|
||||||
ptr->attr = attr;
|
ptr->status = A_CHAR;
|
||||||
|
ptr->attr = attr;
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Write CR status to buffer attribute.
|
||||||
// void WriteCR (const CurPos &)
|
|
||||||
// Write CR status to buffer attribute.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::WriteCR (const CurPos &pos)
|
TermBuffer::WriteCR (const CurPos &pos)
|
||||||
{
|
{
|
||||||
int row = pos.y;
|
int row = pos.y;
|
||||||
int col = pos.x;
|
int col = pos.x;
|
||||||
|
|
||||||
term_buffer *ptr = (mBase[ROW(row)] + col);
|
term_buffer *ptr = (mBase[ROW(row)] + col);
|
||||||
ptr->attr |= DUMPCR;
|
ptr->attr |= DUMPCR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Insert 'num' spaces at cursor point.
|
||||||
// InsertSpace (const CurPos &, int)
|
|
||||||
// Insert num space at cursor point.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::InsertSpace (const CurPos &pos, int num)
|
TermBuffer::InsertSpace (const CurPos &pos, int num)
|
||||||
{
|
{
|
||||||
const int row = pos.y;
|
const int row = pos.y;
|
||||||
const int col = pos.x;
|
const int col = pos.x;
|
||||||
|
|
||||||
for (int i = mNowColSize - num; i >= col; i--) {
|
for (int i = mNowColSize - num; i >= col; i--)
|
||||||
*(mBase[ROW(row)] + i + num) = *(mBase[ROW(row)] + i);
|
*(mBase[ROW(row)] + i + num) = *(mBase[ROW(row)] + i);
|
||||||
}
|
|
||||||
|
memset(mBase[ROW(row)] + col, 0, num * sizeof(term_buffer));
|
||||||
memset(mBase[ROW(row)] + col, 0, num * sizeof(term_buffer));
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// void DeleteChar (const CurPos &, int)
|
// Delete 'num' characters at cursor point.
|
||||||
// Delete num character at cursor point.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::DeleteChar(const CurPos &pos, int num)
|
TermBuffer::DeleteChar(const CurPos &pos, int num)
|
||||||
{
|
{
|
||||||
const int row = pos.y;
|
const int row = pos.y;
|
||||||
const int col = pos.x;
|
const int col = pos.x;
|
||||||
|
|
||||||
term_buffer *ptr = mBase[ROW(row)];
|
term_buffer *ptr = mBase[ROW(row)];
|
||||||
size_t movesize = mNowColSize - (col + num);
|
size_t movesize = mNowColSize - (col + num);
|
||||||
|
|
||||||
memmove (ptr + col, ptr + col + num, movesize * sizeof(term_buffer));
|
memmove (ptr + col, ptr + col + num, movesize * sizeof(term_buffer));
|
||||||
memset (ptr + (mNowColSize - num), 0, num * sizeof(term_buffer));
|
memset (ptr + (mNowColSize - num), 0, num * sizeof(term_buffer));
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Erase characters below cursor position.
|
||||||
// EraseBelow (const CurPos &)
|
|
||||||
// Erase below character from cursor position.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::EraseBelow(const CurPos &pos)
|
TermBuffer::EraseBelow(const CurPos &pos)
|
||||||
{
|
{
|
||||||
const int row = pos.y;
|
const int row = pos.y;
|
||||||
const int col = pos.x;
|
const int col = pos.x;
|
||||||
|
|
||||||
memset (mBase[ROW(row)] + col, 0, (mColSize - col ) * sizeof (term_buffer));
|
memset (mBase[ROW(row)] + col, 0, (mColSize - col ) * sizeof (term_buffer));
|
||||||
|
|
||||||
for (int i = row; i < mRowSize; i++)
|
for (int i = row; i < mRowSize; i++)
|
||||||
EraseLine (i);
|
EraseLine (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Scroll the terminal buffer region
|
||||||
// ScrollRegion (int, int, int, int)
|
|
||||||
// Scroll terminal buffer region.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::ScrollRegion(int top, int bot, int dir, int num)
|
TermBuffer::ScrollRegion(int top, int bot, int dir, int num)
|
||||||
{
|
{
|
||||||
|
if(dir == SCRUP) {
|
||||||
if(dir == SCRUP){
|
for(int i = 0; i < num; i++){
|
||||||
for(int i = 0; i < num; i++){
|
|
||||||
|
term_buffer *ptr = mBase[ROW(top)];
|
||||||
term_buffer *ptr = mBase[ROW(top)];
|
|
||||||
|
for(int j = top; j < bot; j++)
|
||||||
for(int j = top; j < bot; j++){
|
mBase[ROW(j)] = mBase[ROW(j+1)];
|
||||||
mBase[ROW(j)] = mBase[ROW(j+1)];
|
|
||||||
}
|
mBase[ROW(bot)] = ptr;
|
||||||
mBase[ROW(bot)] = ptr;
|
|
||||||
|
EraseLine(bot);
|
||||||
EraseLine(bot);
|
}
|
||||||
}
|
} else {
|
||||||
}else{
|
// scroll up
|
||||||
// scroll up
|
for(int i = 0; i < num; i++){
|
||||||
for(int i = 0; i < num; i++){
|
term_buffer *ptr = mBase[ROW(bot)];
|
||||||
term_buffer *ptr = mBase[ROW(bot)];
|
|
||||||
|
for(int j = bot; j > top; j--)
|
||||||
for(int j = bot; j > top; j--){
|
mBase[ROW(j)] = mBase[ROW(j-1)];
|
||||||
mBase[ROW(j)] = mBase[ROW(j-1)];
|
|
||||||
}
|
mBase[ROW(top)] = ptr;
|
||||||
mBase[ROW(top)] = ptr;
|
|
||||||
|
EraseLine(top);
|
||||||
EraseLine(top);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Scroll the terminal buffer.
|
||||||
// ScrollLine (void)
|
|
||||||
// Scroll terminal buffer.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::ScrollLine(void)
|
TermBuffer::ScrollLine(void)
|
||||||
{
|
{
|
||||||
for (int i = mRowSize; i < mRowSize * 2; i++) {
|
for (int i = mRowSize; i < mRowSize * 2; i++)
|
||||||
EraseLine (i);
|
EraseLine (i);
|
||||||
}
|
|
||||||
|
mRowOffset++;
|
||||||
mRowOffset++;
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// ResizeTo (int, int, int)
|
// Resize the terminal buffer.
|
||||||
// Resize terminal buffer.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::ResizeTo(int newRows, int newCols, int offset)
|
TermBuffer::ResizeTo(int newRows, int newCols, int offset)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
// TODO: Why is this code #if 0'd? It should either be fixed or removed
|
||||||
#if 0
|
#if 0
|
||||||
if (newCols > mColSize) {
|
if (newCols > mColSize) {
|
||||||
for (i = 0; i < buffer_size; i++) {
|
for (i = 0; i < buffer_size; i++) {
|
||||||
mBase[i] = (ulong *) realloc (mBase[i], sizeof(ulong) * newCols);
|
mBase[i] = (ulong *) realloc (mBase[i], sizeof(ulong) * newCols);
|
||||||
base = mBase[i] + mColSize;
|
base = mBase[i] + mColSize;
|
||||||
for (j= 0; j < newCols - mColSize; j++) {
|
for (j= 0; j < newCols - mColSize; j++)
|
||||||
*base++ = 0;
|
*base++ = 0;
|
||||||
}
|
}
|
||||||
}
|
mColSize = newCols;
|
||||||
mColSize = newCols;
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if ( newRows <= mRowSize) {
|
if ( newRows <= mRowSize) {
|
||||||
for (i = newRows; i <= mRowSize; i++) {
|
for (i = newRows; i <= mRowSize; i++)
|
||||||
EraseLine (i);
|
EraseLine (i);
|
||||||
}
|
} else {
|
||||||
} else {
|
for (i = mRowSize; i <= newRows * 2; i++)
|
||||||
for (i = mRowSize; i <= newRows * 2; i++) {
|
EraseLine (i);
|
||||||
EraseLine (i);
|
}
|
||||||
}
|
|
||||||
}
|
mNowColSize = newCols;
|
||||||
|
mRowOffset += offset;
|
||||||
mNowColSize = newCols;
|
mRowSize = newRows;
|
||||||
mRowOffset += offset;
|
|
||||||
mRowSize = newRows;
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Get the buffer's size.
|
||||||
// GetArraySize (void)
|
|
||||||
// Get buffer size.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
int32
|
int32
|
||||||
TermBuffer::GetArraySize (void)
|
TermBuffer::GetArraySize (void)
|
||||||
{
|
{
|
||||||
return buffer_size;
|
return buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Erase one column.
|
||||||
* PRIVATE MEMBER FUNCTIONS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// EraseLine (int)
|
|
||||||
// Erase one column.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::EraseLine (int row)
|
TermBuffer::EraseLine (int row)
|
||||||
{
|
{
|
||||||
memset (mBase[ROW(row)], 0, mColSize * sizeof (term_buffer));
|
memset (mBase[ROW(row)], 0, mColSize * sizeof (term_buffer));
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// ClearAll()
|
// Clear the contents of the TermBuffer.
|
||||||
// Clear contents of TermBuffer.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::ClearAll (void)
|
TermBuffer::ClearAll (void)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < buffer_size; i++){
|
for(int i = 0; i < buffer_size; i++)
|
||||||
memset (mBase[i], 0, mColSize * sizeof (term_buffer));
|
memset (mBase[i], 0, mColSize * sizeof (term_buffer));
|
||||||
}
|
|
||||||
mRowOffset = 0;
|
mRowOffset = 0;
|
||||||
this->DeSelect ();
|
DeSelect ();
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Select()
|
// Mark text in the given range as selected
|
||||||
// Mark Text Selected to given range.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::Select(const CurPos &start, const CurPos &end)
|
TermBuffer::Select(const CurPos &start, const CurPos &end)
|
||||||
{
|
{
|
||||||
|
if (end < start) {
|
||||||
if (end < start) {
|
mSelStart = end;
|
||||||
mSelStart = end;
|
mSelEnd = start;
|
||||||
mSelEnd = start;
|
} else {
|
||||||
}
|
mSelStart = start;
|
||||||
else {
|
mSelEnd = end;
|
||||||
mSelStart = start;
|
}
|
||||||
mSelEnd = end;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// DeSelect()
|
// Mark text in the given range as not selected
|
||||||
// Mark Text UnSelected to given range.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::DeSelect (void)
|
TermBuffer::DeSelect (void)
|
||||||
{
|
{
|
||||||
|
mSelStart.Set (-1, -1);
|
||||||
mSelStart.Set (-1, -1);
|
mSelEnd.Set (-1, -1);
|
||||||
mSelEnd.Set (-1, -1);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CheckSelectedRegion (CurPos &)
|
// Check cursor position which be including selected area.
|
||||||
// Check cursor position which be including selected area.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
int
|
int
|
||||||
TermBuffer::CheckSelectedRegion (const CurPos &pos)
|
TermBuffer::CheckSelectedRegion (const CurPos &pos)
|
||||||
{
|
{
|
||||||
|
return (mSelStart.y == pos.y || mSelEnd.y == pos.y);
|
||||||
if (mSelStart.y == pos.y || mSelEnd.y == pos.y) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// FindWord (CurPos &, CurPos *, CurPos *)
|
// Find a word in the TermBuffer
|
||||||
// Find word from TermBuffer
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool
|
bool
|
||||||
TermBuffer::FindWord(const CurPos &pos, CurPos *start, CurPos *end)
|
TermBuffer::FindWord(const CurPos &pos, CurPos *start, CurPos *end)
|
||||||
{
|
{
|
||||||
uchar buf[5];
|
uchar buf[5];
|
||||||
ushort attr;
|
ushort attr;
|
||||||
int x, y, start_x;
|
int x, y, start_x;
|
||||||
|
|
||||||
y = pos.y;
|
y = pos.y;
|
||||||
|
|
||||||
// Search start point
|
// Search start point
|
||||||
for(x = pos.x - 1; x >= 0; x--){
|
for(x = pos.x - 1; x >= 0; x--){
|
||||||
if((this->GetChar (y, x, buf, &attr) == NO_CHAR) || (*buf == ' ')){
|
if((this->GetChar (y, x, buf, &attr) == NO_CHAR) || (*buf == ' ')){
|
||||||
++x;
|
++x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start_x = x;
|
start_x = x;
|
||||||
|
|
||||||
// Search end point
|
// Search end point
|
||||||
for(x = pos.x; x < mColSize; x++){
|
for(x = pos.x; x < mColSize; x++){
|
||||||
if((this->GetChar (y, x, buf, &attr) == NO_CHAR) || (*buf == ' ')){
|
if( (GetChar(y, x, buf, &attr) == NO_CHAR) || (*buf == ' ')) {
|
||||||
--x;
|
--x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start_x > x) return false;
|
if(start_x > x)
|
||||||
|
return false;
|
||||||
mSelStart.Set(start_x, y);
|
|
||||||
if (start != NULL){
|
mSelStart.Set(start_x, y);
|
||||||
start->Set(start_x, y);
|
if(start != NULL)
|
||||||
}
|
start->Set(start_x, y);
|
||||||
|
|
||||||
mSelEnd.Set(x, y);
|
mSelEnd.Set(x, y);
|
||||||
if (end != NULL){
|
if(end != NULL)
|
||||||
end->Set(x, y);
|
end->Set(x, y);
|
||||||
}
|
|
||||||
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// GetCharFromRegion (int, int, BString)
|
// Get one character from the selected region.
|
||||||
// Get one character from selected region.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::GetCharFromRegion (int x, int y, BString &str)
|
TermBuffer::GetCharFromRegion (int x, int y, BString &str)
|
||||||
{
|
{
|
||||||
uchar buf[5];
|
uchar buf[5];
|
||||||
ushort attr;
|
ushort attr;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = GetChar(y, x, buf, &attr);
|
status = GetChar(y, x, buf, &attr);
|
||||||
|
|
||||||
switch(status){
|
switch(status) {
|
||||||
case NO_CHAR:
|
|
||||||
if (IS_CR (attr)) {
|
case NO_CHAR:
|
||||||
str += '\n';
|
if (IS_CR (attr))
|
||||||
} else {
|
str += '\n';
|
||||||
str += ' ';
|
else
|
||||||
}
|
str += ' ';
|
||||||
|
break;
|
||||||
break;
|
|
||||||
|
case IN_STRING:
|
||||||
case IN_STRING:
|
break;
|
||||||
break;
|
|
||||||
|
default:
|
||||||
default:
|
str += (const char *)&buf;
|
||||||
str += (const char *)&buf;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Delete useless char at end of line and convert LF code.
|
||||||
// AvoidWaste (BString str)
|
|
||||||
// Delete useless char at end of line, and convert LF code.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
inline void
|
inline void
|
||||||
TermBuffer::AvoidWaste (BString &str)
|
TermBuffer::AvoidWaste (BString &str)
|
||||||
{
|
{
|
||||||
int32 len, point;
|
// TODO: Remove the goto
|
||||||
|
|
||||||
start:
|
int32 len, point;
|
||||||
len = str.Length() - 1;
|
|
||||||
point = str.FindLast (' ');
|
start:
|
||||||
|
|
||||||
if (len > 0 && len == point) {
|
len = str.Length() - 1;
|
||||||
str.RemoveLast (" ");
|
point = str.FindLast (' ');
|
||||||
goto start;
|
|
||||||
}
|
if (len > 0 && len == point) {
|
||||||
|
str.RemoveLast (" ");
|
||||||
// str += '\n';
|
goto start;
|
||||||
return;
|
}
|
||||||
|
// str += '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
// Get a string from selected region.
|
||||||
// GetStringFromRegion (BString str)
|
|
||||||
// Get string from selected region.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermBuffer::GetStringFromRegion(BString &str)
|
TermBuffer::GetStringFromRegion(BString &str)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
if(mSelStart.y == mSelEnd.y){
|
if(mSelStart.y == mSelEnd.y) {
|
||||||
y = mSelStart.y;
|
y = mSelStart.y;
|
||||||
for(int x = mSelStart.x ; x <= mSelEnd.x; x++){
|
for(int x = mSelStart.x ; x <= mSelEnd.x; x++)
|
||||||
GetCharFromRegion (x, y, str);
|
GetCharFromRegion (x, y, str);
|
||||||
}
|
} else {
|
||||||
}else{
|
y = mSelStart.y;
|
||||||
y = mSelStart.y;
|
for(int x = mSelStart.x ; x < mNowColSize; x++)
|
||||||
for(int x = mSelStart.x ; x < mNowColSize; x++){
|
GetCharFromRegion (x, y, str);
|
||||||
GetCharFromRegion (x, y, str);
|
AvoidWaste (str);
|
||||||
}
|
|
||||||
AvoidWaste (str);
|
for(y = mSelStart.y + 1 ; y < mSelEnd.y; y++){
|
||||||
|
for(int x = 0 ; x < mNowColSize; x++)
|
||||||
for(y = mSelStart.y + 1 ; y < mSelEnd.y; y++){
|
GetCharFromRegion (x, y, str);
|
||||||
for(int x = 0 ; x < mNowColSize; x++){
|
AvoidWaste (str);
|
||||||
GetCharFromRegion (x, y, str);
|
}
|
||||||
}
|
|
||||||
AvoidWaste (str);
|
y = mSelEnd.y;
|
||||||
}
|
for(int x = 0 ; x <= mSelEnd.x; x++)
|
||||||
y = mSelEnd.y;
|
GetCharFromRegion (x, y, str);
|
||||||
for(int x = 0 ; x <= mSelEnd.x; x++){
|
}
|
||||||
GetCharFromRegion (x, y, str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1871
-2233
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user