* Fixed broken CodeConv semantics (missing length parameter).
* No longer writes to the message data from clipboard. * some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15153 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+54
-104
@@ -1,34 +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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/************************************************************************
|
/*********************************************************************
|
||||||
MuTerminal Code Conversion class (MC3).
|
MuTerminal Code Conversion class (MC3).
|
||||||
|
|
||||||
version 1.1 Internal coding system is UTF8.
|
version 1.1 Internal coding system is UTF8.
|
||||||
@@ -52,26 +29,20 @@ UTF8
|
|||||||
|
|
||||||
extern char utf8_width_table[]; /* define UTF8WidthTbl.c */
|
extern char utf8_width_table[]; /* define UTF8WidthTbl.c */
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Constructor
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
CodeConv::CodeConv (void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
CodeConv::CodeConv()
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Destructor
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
CodeConv::~CodeConv (void)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// UTF8GetFontWidth (const uchar *string)
|
|
||||||
// get font width in coding.
|
CodeConv::~CodeConv()
|
||||||
//////////////////////////////////////////////////////////////////////
|
{
|
||||||
int
|
}
|
||||||
CodeConv::UTF8GetFontWidth (const uchar *string)
|
|
||||||
|
|
||||||
|
//! get font width in coding.
|
||||||
|
int32
|
||||||
|
CodeConv::UTF8GetFontWidth(const char *string)
|
||||||
{
|
{
|
||||||
uchar width, point;
|
uchar width, point;
|
||||||
ushort unicode, offset;
|
ushort unicode, offset;
|
||||||
@@ -82,33 +53,34 @@ CodeConv::UTF8GetFontWidth (const uchar *string)
|
|||||||
|
|
||||||
point = 0x80 >> offset;
|
point = 0x80 >> offset;
|
||||||
|
|
||||||
return ((width & point) > 0 ) ? 2 : 1;
|
return (width & point) > 0 ? 2 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// ConvertFromInternal (const uchar *src, uchar *dst, int coding)
|
//! Convert internal coding from src coding.
|
||||||
// Convert internal coding from src coding.
|
int32
|
||||||
//////////////////////////////////////////////////////////////////////
|
CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding)
|
||||||
int
|
|
||||||
CodeConv::ConvertFromInternal (const uchar *src, uchar *dst, int coding)
|
|
||||||
{
|
{
|
||||||
const uchar *src_p = src;
|
int32 dstlen = 0;
|
||||||
long srclen = 0, dstlen = 0;
|
|
||||||
long state = 0;
|
long state = 0;
|
||||||
int theCoding;
|
int theCoding;
|
||||||
|
|
||||||
if (coding == M_UTF8) return 0;
|
if (srclen == -1)
|
||||||
|
srclen = strlen(src);
|
||||||
|
|
||||||
|
if (coding == M_UTF8) {
|
||||||
|
memcpy(dst, src, srclen);
|
||||||
|
dst[srclen] = '\0';
|
||||||
|
return srclen;
|
||||||
|
}
|
||||||
|
|
||||||
theCoding = coding_translation_table[coding];
|
theCoding = coding_translation_table[coding];
|
||||||
|
|
||||||
while (*src_p++) srclen++;
|
|
||||||
|
|
||||||
dstlen = srclen * 256;
|
dstlen = srclen * 256;
|
||||||
|
|
||||||
convert_from_utf8 (theCoding,
|
convert_from_utf8(theCoding, (char *)src, &srclen,
|
||||||
(char *)src, &srclen,
|
(char *)dst, &dstlen, &state, '?');
|
||||||
(char *)dst, &dstlen,
|
|
||||||
&state, '?');
|
|
||||||
|
|
||||||
if (coding == M_ISO_2022_JP && state != 0) {
|
if (coding == M_ISO_2022_JP && state != 0) {
|
||||||
const char *end_of_jis = "(B";
|
const char *end_of_jis = "(B";
|
||||||
@@ -117,24 +89,26 @@ CodeConv::ConvertFromInternal (const uchar *src, uchar *dst, int coding)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dst[dstlen] = '\0';
|
dst[dstlen] = '\0';
|
||||||
|
|
||||||
return dstlen;
|
return dstlen;
|
||||||
|
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// ConvertToInternal (const uchar *src, uchar *dst, int coding)
|
|
||||||
// Convert internal coding to src coding.
|
//! Convert internal coding to src coding.
|
||||||
//////////////////////////////////////////////////////////////////////
|
int32
|
||||||
void
|
CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding)
|
||||||
CodeConv::ConvertToInternal (const uchar *src, uchar *dst, int coding)
|
|
||||||
{
|
{
|
||||||
const uchar *src_p = src;
|
int32 dstlen = 4;
|
||||||
long srclen = 0, dstlen = 4;
|
|
||||||
long state = 0;
|
long state = 0;
|
||||||
int theCoding;
|
int theCoding;
|
||||||
|
|
||||||
|
if (srclen == -1)
|
||||||
|
srclen = strlen(src);
|
||||||
|
|
||||||
if (coding == M_UTF8) return;
|
if (coding == M_UTF8) {
|
||||||
|
memcpy(dst, src, srclen);
|
||||||
|
dst[srclen] = '\0';
|
||||||
|
return srclen;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#ifndef __INTEL__
|
#ifndef __INTEL__
|
||||||
@@ -149,34 +123,21 @@ CodeConv::ConvertToInternal (const uchar *src, uchar *dst, int coding)
|
|||||||
dst[dstlen] = '\0';
|
dst[dstlen] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
theCoding = coding_translation_table[coding];
|
theCoding = coding_translation_table[coding];
|
||||||
|
|
||||||
while (*src_p++) srclen++;
|
convert_to_utf8(theCoding, (char *)src, &srclen,
|
||||||
|
(char *)dst, &dstlen, &state, '?');
|
||||||
convert_to_utf8 (theCoding,
|
|
||||||
(char *)src, &srclen,
|
|
||||||
(char *)dst, &dstlen,
|
|
||||||
&state, '?');
|
|
||||||
|
|
||||||
dst[dstlen] = '\0';
|
dst[dstlen] = '\0';
|
||||||
|
return dstlen;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Private member functions.
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// UTF8toUnicode (uchar *utf8)
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
unsigned short
|
unsigned short
|
||||||
CodeConv::UTF8toUnicode (const uchar *utf8)
|
CodeConv::UTF8toUnicode(const char *utf8)
|
||||||
{
|
{
|
||||||
uchar tmp;
|
uchar tmp;
|
||||||
unsigned short unicode = 0x0000;
|
unsigned short unicode = 0x0000;
|
||||||
@@ -185,13 +146,11 @@ CodeConv::UTF8toUnicode (const uchar *utf8)
|
|||||||
|
|
||||||
if (tmp < 0x80) {
|
if (tmp < 0x80) {
|
||||||
unicode = (unsigned short)*utf8;
|
unicode = (unsigned short)*utf8;
|
||||||
}
|
} else if (tmp < 0xe0) {
|
||||||
else if (tmp < 0xe0) {
|
|
||||||
unicode = (unsigned short)*utf8++ & 0x1f;
|
unicode = (unsigned short)*utf8++ & 0x1f;
|
||||||
unicode = unicode << 6;
|
unicode = unicode << 6;
|
||||||
unicode = unicode | ((unsigned short)*utf8 & 0x3f);
|
unicode = unicode | ((unsigned short)*utf8 & 0x3f);
|
||||||
}
|
} else if (tmp < 0xf0) {
|
||||||
else if (tmp < 0xf0) {
|
|
||||||
unicode = (unsigned short)*utf8++ & 0x0f;
|
unicode = (unsigned short)*utf8++ & 0x0f;
|
||||||
unicode = unicode << 6;
|
unicode = unicode << 6;
|
||||||
unicode = unicode | ((unsigned short)*utf8++ & 0x3f);
|
unicode = unicode | ((unsigned short)*utf8++ & 0x3f);
|
||||||
@@ -202,10 +161,7 @@ CodeConv::UTF8toUnicode (const uchar *utf8)
|
|||||||
return unicode;
|
return unicode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// euc_to_sjis
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
CodeConv::euc_to_sjis(uchar *buf)
|
CodeConv::euc_to_sjis(uchar *buf)
|
||||||
{
|
{
|
||||||
@@ -223,22 +179,16 @@ CodeConv::euc_to_sjis (uchar *buf)
|
|||||||
c1 = p / 188;
|
c1 = p / 188;
|
||||||
c2 = p % 188;
|
c2 = p % 188;
|
||||||
|
|
||||||
if (c1 >= 31) {
|
if (c1 >= 31)
|
||||||
c1 = c1 - 31 + 0xE0;
|
c1 = c1 - 31 + 0xE0;
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
c1 += 0x81;
|
c1 += 0x81;
|
||||||
}
|
|
||||||
|
|
||||||
if (c2 >= 63) {
|
if (c2 >= 63)
|
||||||
c2 = c2 - 63 + 0x80;
|
c2 = c2 - 63 + 0x80;
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
c2 += 0x40;
|
c2 += 0x40;
|
||||||
}
|
|
||||||
|
|
||||||
*buf++ = c1;
|
*buf++ = c1;
|
||||||
*buf = c2;
|
*buf = c2;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,83 +1,37 @@
|
|||||||
/*
|
/*
|
||||||
|
* 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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CODECONV_H
|
#ifndef CODECONV_H
|
||||||
#define CODECONV_H
|
#define CODECONV_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include "Coding.h"
|
#include "Coding.h"
|
||||||
|
|
||||||
#define BEGINS_CHAR(byte) ((byte & 0xc0) >= 0x80)
|
#define BEGINS_CHAR(byte) ((byte & 0xc0) >= 0x80)
|
||||||
|
|
||||||
/*
|
class CodeConv {
|
||||||
* Coding system define.
|
|
||||||
*/
|
|
||||||
class CodeConv
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Constructor and Destuructor.
|
|
||||||
*/
|
|
||||||
public:
|
public:
|
||||||
CodeConv (void);
|
CodeConv();
|
||||||
~CodeConv (void);
|
~CodeConv();
|
||||||
|
|
||||||
/*
|
int32 UTF8GetFontWidth(const char *string);
|
||||||
* Public member functions.
|
|
||||||
*/
|
|
||||||
int UTF8GetFontWidth (const uchar *string);
|
|
||||||
|
|
||||||
/* internal(UTF8) -> coding */
|
/* internal(UTF8) -> coding */
|
||||||
int ConvertFromInternal (const uchar *src, uchar *dst, int coding);
|
int32 ConvertFromInternal(const char *src, int32 bytes, char *dst, int coding);
|
||||||
|
|
||||||
/* coding -> internal(UTF8) */
|
/* coding -> internal(UTF8) */
|
||||||
void ConvertToInternal (const uchar *src, uchar *dst, int coding);
|
int32 ConvertToInternal(const char *src, int32 bytes, char *dst, int coding);
|
||||||
|
|
||||||
/*
|
|
||||||
* PRIVATE MEMBER.
|
|
||||||
*/
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
|
||||||
* Private member functions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void euc_to_sjis(uchar *buf);
|
void euc_to_sjis(uchar *buf);
|
||||||
|
|
||||||
unsigned short UTF8toUnicode (const uchar *utf8);
|
unsigned short UTF8toUnicode(const char *utf8);
|
||||||
|
|
||||||
/*
|
|
||||||
* DATA Member.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int fNowCoding;
|
int fNowCoding;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CODECONV_H */
|
#endif /* CODECONV_H */
|
||||||
|
|||||||
@@ -3,13 +3,19 @@
|
|||||||
* 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.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Kian Duffy <[email protected]>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! This view is a shell for the TermView and makes sure it's always
|
||||||
|
resized in whole character sizes.
|
||||||
|
It doesn't serve any other purpose (and could possibly removed
|
||||||
|
with a tiny bit smarter programming).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "TermBaseView.h"
|
#include "TermBaseView.h"
|
||||||
#include "TermView.h"
|
#include "TermView.h"
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -17,20 +23,22 @@ TermBaseView::TermBaseView (BRect frame, TermView *inTermView)
|
|||||||
fTermView = inTermView;
|
fTermView = inTermView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TermBaseView::~TermBaseView()
|
TermBaseView::~TermBaseView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermBaseView::FrameResized(float width, float height)
|
TermBaseView::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
int font_width, font_height;
|
int fontWidth, fontHeight;
|
||||||
int cols, rows;
|
int cols, rows;
|
||||||
|
|
||||||
fTermView->GetFontInfo (&font_width, &font_height);
|
fTermView->GetFontInfo(&fontWidth, &fontHeight);
|
||||||
|
|
||||||
cols = (int)(width - VIEW_OFFSET * 2) / font_width;
|
cols = (int)(width - VIEW_OFFSET * 2) / fontWidth;
|
||||||
rows = (int)(height - VIEW_OFFSET * 2)/ font_height;
|
rows = (int)(height - VIEW_OFFSET * 2) / fontHeight;
|
||||||
|
|
||||||
fTermView->ResizeTo (cols * font_width - 1, rows * font_height - 1);
|
fTermView->ResizeTo(cols * fontWidth - 1, rows * fontHeight - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
|
* 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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
#ifndef TERM_BASE_VIEW_H
|
||||||
|
#define TERM_BASE_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#ifndef TERMBASEVIEW_H_INCLUDED
|
|
||||||
#define TERMBASEVIEW_H_INCLUDED
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
class TermView;
|
class TermView;
|
||||||
|
|
||||||
class TermBaseView : public BView
|
|
||||||
{
|
class TermBaseView : public BView {
|
||||||
public:
|
public:
|
||||||
//
|
|
||||||
// Constructor and Desctructor
|
|
||||||
//
|
|
||||||
TermBaseView(BRect frame, TermView *);
|
TermBaseView(BRect frame, TermView *);
|
||||||
~TermBaseView();
|
~TermBaseView();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//
|
|
||||||
// Hook Functions.
|
|
||||||
//
|
|
||||||
void SetBaseColor(rgb_color);
|
void SetBaseColor(rgb_color);
|
||||||
|
virtual void FrameResized(float newWidth, float newHeight);
|
||||||
void FrameResized (float, float);
|
|
||||||
|
|
||||||
TermView *fTermView;
|
TermView *fTermView;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TERMBASEVIEW_H_INCLUDED */
|
#endif /* TERM_BASE_VIEW_H */
|
||||||
|
|||||||
@@ -1,33 +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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -253,6 +231,7 @@ int gNowCoding = M_UTF8;
|
|||||||
#define DEFAULT -1
|
#define DEFAULT -1
|
||||||
#define NPARAM 10 // Max parameters
|
#define NPARAM 10 // Max parameters
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
TermParse::EscParse(void *data)
|
TermParse::EscParse(void *data)
|
||||||
{
|
{
|
||||||
@@ -322,9 +301,8 @@ TermParse::EscParse (void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (parsestate[c]) {
|
switch (parsestate[c]) {
|
||||||
|
|
||||||
case CASE_PRINT:
|
case CASE_PRINT:
|
||||||
cbuf[0] = (uchar) c;
|
cbuf[0] = c;
|
||||||
cbuf[1] = '\0';
|
cbuf[1] = '\0';
|
||||||
width = HALF_WIDTH;
|
width = HALF_WIDTH;
|
||||||
viewObj->PutChar(cbuf, attr, width);
|
viewObj->PutChar(cbuf, attr, width);
|
||||||
@@ -333,9 +311,8 @@ TermParse::EscParse (void *data)
|
|||||||
case CASE_PRINT_GR:
|
case CASE_PRINT_GR:
|
||||||
/* case iso8859 gr character, or euc */
|
/* case iso8859 gr character, or euc */
|
||||||
ptr = cbuf;
|
ptr = cbuf;
|
||||||
if (now_coding == M_EUC_JP || now_coding == M_EUC_KR ||
|
if (now_coding == M_EUC_JP || now_coding == M_EUC_KR
|
||||||
now_coding == M_ISO_2022_JP) {
|
|| now_coding == M_ISO_2022_JP) {
|
||||||
|
|
||||||
switch (parsestate[curess]) {
|
switch (parsestate[curess]) {
|
||||||
case CASE_SS2: /* JIS X 0201 */
|
case CASE_SS2: /* JIS X 0201 */
|
||||||
*ptr++ = curess;
|
*ptr++ = curess;
|
||||||
@@ -361,17 +338,17 @@ TermParse::EscParse (void *data)
|
|||||||
width = 2;
|
width = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else { /* ISO-8859-1...10 and MacRoman */
|
} else {
|
||||||
|
/* ISO-8859-1...10 and MacRoman */
|
||||||
*ptr++ = c;
|
*ptr++ = c;
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
width = 1;
|
width = 1;
|
||||||
}
|
}
|
||||||
if (now_coding != M_ISO_2022_JP) {
|
|
||||||
convObj->ConvertToInternal (cbuf, dstbuf, now_coding);
|
if (now_coding != M_ISO_2022_JP)
|
||||||
}
|
convObj->ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, now_coding);
|
||||||
else {
|
else
|
||||||
convObj->ConvertToInternal (cbuf, dstbuf, M_EUC_JP);
|
convObj->ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, M_EUC_JP);
|
||||||
}
|
|
||||||
|
|
||||||
viewObj->PutChar(dstbuf, attr, width);
|
viewObj->PutChar(dstbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
@@ -381,7 +358,7 @@ TermParse::EscParse (void *data)
|
|||||||
cbuf[1] = theObj->GetReaderBuf() | 0x80;
|
cbuf[1] = theObj->GetReaderBuf() | 0x80;
|
||||||
cbuf[2] = 0;
|
cbuf[2] = 0;
|
||||||
width = 2;
|
width = 2;
|
||||||
convObj->ConvertToInternal (cbuf, dstbuf, M_EUC_JP);
|
convObj->ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, M_EUC_JP);
|
||||||
viewObj->PutChar(dstbuf, attr, width);
|
viewObj->PutChar(dstbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -396,7 +373,7 @@ TermParse::EscParse (void *data)
|
|||||||
case CASE_SJIS_KANA:
|
case CASE_SJIS_KANA:
|
||||||
cbuf[0] = (uchar)c;
|
cbuf[0] = (uchar)c;
|
||||||
cbuf[1] = '\0';
|
cbuf[1] = '\0';
|
||||||
convObj->ConvertToInternal (cbuf, dstbuf, now_coding);
|
convObj->ConvertToInternal((char*)cbuf, 1, (char*)dstbuf, now_coding);
|
||||||
width = 1;
|
width = 1;
|
||||||
viewObj->PutChar(dstbuf, attr, width);
|
viewObj->PutChar(dstbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
@@ -405,7 +382,7 @@ TermParse::EscParse (void *data)
|
|||||||
cbuf[0] = (uchar)c;
|
cbuf[0] = (uchar)c;
|
||||||
cbuf[1] = theObj->GetReaderBuf();
|
cbuf[1] = theObj->GetReaderBuf();
|
||||||
cbuf[2] = '\0';
|
cbuf[2] = '\0';
|
||||||
convObj->ConvertToInternal (cbuf, dstbuf, now_coding);
|
convObj->ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, now_coding);
|
||||||
width = 2;
|
width = 2;
|
||||||
viewObj->PutChar(dstbuf, attr, width);
|
viewObj->PutChar(dstbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
@@ -417,24 +394,23 @@ TermParse::EscParse (void *data)
|
|||||||
break;
|
break;
|
||||||
cbuf[1] = (uchar)c;
|
cbuf[1] = (uchar)c;
|
||||||
cbuf[2] = '\0';
|
cbuf[2] = '\0';
|
||||||
width = convObj->UTF8GetFontWidth (cbuf);
|
width = convObj->UTF8GetFontWidth((char*)cbuf);
|
||||||
viewObj->PutChar(cbuf, attr, width);
|
viewObj->PutChar(cbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_UTF8_3BYTE:
|
case CASE_UTF8_3BYTE:
|
||||||
cbuf[0] = (uchar) c;
|
cbuf[0] = c;
|
||||||
c = theObj->GetReaderBuf();
|
c = theObj->GetReaderBuf();
|
||||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||||
break;
|
break;
|
||||||
cbuf[1] = (uchar) c;
|
cbuf[1] = c;
|
||||||
|
|
||||||
c = theObj->GetReaderBuf();
|
c = theObj->GetReaderBuf();
|
||||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||||
break;
|
break;
|
||||||
cbuf[2] = (uchar) c;
|
cbuf[2] = c;
|
||||||
|
|
||||||
cbuf[3] = '\0';
|
cbuf[3] = '\0';
|
||||||
width = convObj->UTF8GetFontWidth (cbuf);
|
width = convObj->UTF8GetFontWidth((char*)cbuf);
|
||||||
viewObj->PutChar (cbuf, attr, width);
|
viewObj->PutChar (cbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -575,7 +551,6 @@ TermParse::EscParse (void *data)
|
|||||||
col = 1;
|
col = 1;
|
||||||
|
|
||||||
viewObj->SetCurPos(col - 1, row - 1 );
|
viewObj->SetCurPos(col - 1, row - 1 );
|
||||||
|
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -713,19 +688,17 @@ TermParse::EscParse (void *data)
|
|||||||
if ((top = param[0]) < 1)
|
if ((top = param[0]) < 1)
|
||||||
top = 1;
|
top = 1;
|
||||||
|
|
||||||
if(nparam < 2) {
|
if (nparam < 2)
|
||||||
bot = -1;
|
bot = -1;
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
bot = param[1];
|
bot = param[1];
|
||||||
}
|
|
||||||
|
|
||||||
top--;
|
top--;
|
||||||
bot--;
|
bot--;
|
||||||
|
|
||||||
if (bot > top) {
|
if (bot > top)
|
||||||
viewObj->SetScrollRegion(top, bot);
|
viewObj->SetScrollRegion(top, bot);
|
||||||
}
|
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+199
-212
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user