Implemented input method handling. Unfortunately, due to bug #4926, it's

completely unusable (it's disabled currently anyway).
Shell::AttachBuffer() returns a status_t now (instead of void), so the caller
can do something in case it fails.
Simplified some methods, removed unused stuff.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34707 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2009-12-19 17:27:39 +00:00
parent 83f19b6734
commit 8c6aa65eb6
15 changed files with 513 additions and 120 deletions
+23 -38
View File
@@ -11,7 +11,6 @@
struct etable {
const char *name; // long name for menu item.
const char *shortname; // short name (use for command-line etc.)
const char shortcut; // short cut key code
const int32 id; // encoding id
};
@@ -19,38 +18,38 @@ struct etable {
* encoding_table ... use encoding menu, message, and preference keys.
*/
const static etable kEncodingTable[] = {
{"UTF-8", "UTF8", 'U', M_UTF8},
{"ISO-8859-1", "8859-1", '1', B_ISO1_CONVERSION},
{"ISO-8859-2", "8859-2", '2', B_ISO2_CONVERSION},
{"ISO-8859-3", "8859-3", '3', B_ISO3_CONVERSION},
{"ISO-8859-4", "8859-4", '4', B_ISO4_CONVERSION},
{"ISO-8859-5", "8859-5", '5', B_ISO5_CONVERSION},
{"ISO-8859-6", "8859-6", '6', B_ISO6_CONVERSION},
{"ISO-8859-7", "8859-7", '7', B_ISO7_CONVERSION},
{"ISO-8859-8", "8859-8", '8', B_ISO8_CONVERSION},
{"ISO-8859-9", "8859-9", '9', B_ISO9_CONVERSION},
{"ISO-8859-10", "8859-10", '0', B_ISO10_CONVERSION},
{"MacRoman", "MacRoman", 'M', B_MAC_ROMAN_CONVERSION},
{"JIS", "JIS", 'J', B_JIS_CONVERSION},
{"Shift-JIS", "SJIS", 'S', B_SJIS_CONVERSION},
{"EUC-jp", "EUCJ", 'E', B_EUC_CONVERSION},
{"EUC-kr", "EUCK", 'K', B_EUC_KR_CONVERSION},
{"GB18030", "GB18030", 0, B_GBK_CONVERSION},
{"Big5", "Big5", 'B', B_BIG5_CONVERSION},
{"UTF-8", "UTF8", M_UTF8},
{"ISO-8859-1", "8859-1", B_ISO1_CONVERSION},
{"ISO-8859-2", "8859-2", B_ISO2_CONVERSION},
{"ISO-8859-3", "8859-3", B_ISO3_CONVERSION},
{"ISO-8859-4", "8859-4", B_ISO4_CONVERSION},
{"ISO-8859-5", "8859-5", B_ISO5_CONVERSION},
{"ISO-8859-6", "8859-6", B_ISO6_CONVERSION},
{"ISO-8859-7", "8859-7", B_ISO7_CONVERSION},
{"ISO-8859-8", "8859-8", B_ISO8_CONVERSION},
{"ISO-8859-9", "8859-9", B_ISO9_CONVERSION},
{"ISO-8859-10", "8859-10", B_ISO10_CONVERSION},
{"MacRoman", "MacRoman", B_MAC_ROMAN_CONVERSION},
{"JIS", "JIS", B_JIS_CONVERSION},
{"Shift-JIS", "SJIS", B_SJIS_CONVERSION},
{"EUC-jp", "EUCJ", B_EUC_CONVERSION},
{"EUC-kr", "EUCK", B_EUC_KR_CONVERSION},
{"GB18030", "GB18030", B_GBK_CONVERSION},
{"Big5", "Big5", B_BIG5_CONVERSION},
/* Not Implemented.
{"EUC-tw", "EUCT", "T", M_EUC_TW},
{"ISO-2022-cn", "ISOC", 'C', M_ISO_2022_CN},
{"ISO-2022-kr", "ISOK", 'R', M_ISO_2022_KR},
{"EUC-tw", "EUCT", M_EUC_TW},
{"ISO-2022-cn", "ISOC", M_ISO_2022_CN},
{"ISO-2022-kr", "ISOK", M_ISO_2022_KR},
*/
{NULL, NULL, 0, 0},
{NULL, NULL, 0},
};
status_t
get_nth_encoding(int i, int *id)
get_next_encoding(int i, int *id)
{
if (id == NULL)
return B_BAD_VALUE;
@@ -106,17 +105,3 @@ EncodingAsString(int id)
return kEncodingTable[0].name;
}
const char
id2shortcut(int id)
{
const etable *p = kEncodingTable;
while (p->name) {
if (id == p->id)
return p->shortcut;
p++;
}
return kEncodingTable[0].shortcut;
}
+1 -2
View File
@@ -37,12 +37,11 @@
#define M_UTF8 (-1)
status_t get_nth_encoding(int i, int *id);
status_t get_next_encoding(int i, int *id);
int EncodingID(const char *longname);
const char * EncodingAsShortString(int id);
const char * EncodingAsString(int id);
const char id2shortcut(int id);
#endif /* _CODING_H_ */
+4 -3
View File
@@ -20,12 +20,13 @@
const uint32 MSG_FIND_HIDE = 'Fhid';
const BRect kWindowFrame(0, 0, 240, 170);
FindWindow::FindWindow(BRect frame, BMessenger messenger, BString &str,
FindWindow::FindWindow(BMessenger messenger, BString &str,
bool findSelection, bool matchWord, bool matchCase,
bool forwardSearch)
:
BWindow(frame, "Find", B_FLOATING_WINDOW,
BWindow(kWindowFrame, "Find", B_FLOATING_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE
| B_AUTO_UPDATE_SIZE_LIMITS),
fFindDlgMessenger(messenger)
@@ -82,7 +83,7 @@ FindWindow::FindWindow(BRect frame, BMessenger messenger, BString &str,
AddShortcut((ulong)'W', (ulong)B_COMMAND_KEY,
new BMessage(MSG_FIND_HIDE));
Show();
}
+1 -1
View File
@@ -22,7 +22,7 @@ class BCheckBox;
class FindWindow : public BWindow {
public:
FindWindow (BRect frame, BMessenger messenger, BString &str,
FindWindow (BMessenger messenger, BString &str,
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch);
virtual ~FindWindow();
+146
View File
@@ -0,0 +1,146 @@
/*
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
*/
#include "InlineInput.h"
#include <cstdlib>
struct clause
{
int32 start;
int32 end;
};
InlineInput::InlineInput(BMessenger messenger)
:
fMessenger(messenger),
fActive(false),
fSelectionOffset(0),
fSelectionLength(0),
fNumClauses(0),
fClauses(NULL)
{
}
InlineInput::~InlineInput()
{
ResetClauses();
}
const BMessenger *
InlineInput::Method() const
{
return &fMessenger;
}
const char *
InlineInput::String() const
{
return fString.String();
}
void
InlineInput::SetString(const char *string)
{
fString = string;
}
bool
InlineInput::IsActive() const
{
return fActive;
}
void
InlineInput::SetActive(bool active)
{
fActive = active;
}
int32
InlineInput::SelectionLength() const
{
return fSelectionLength;
}
void
InlineInput::SetSelectionLength(int32 length)
{
fSelectionLength = length;
}
int32
InlineInput::SelectionOffset() const
{
return fSelectionOffset;
}
void
InlineInput::SetSelectionOffset(int32 offset)
{
fSelectionOffset = offset;
}
bool
InlineInput::AddClause(int32 start, int32 end)
{
void *newData = realloc(fClauses, (fNumClauses + 1) * sizeof(clause));
if (newData == NULL)
return false;
fClauses = (clause *)newData;
fClauses[fNumClauses].start = start;
fClauses[fNumClauses].end = end;
fNumClauses++;
return true;
}
bool
InlineInput::GetClause(int32 index, int32 *start, int32 *end) const
{
bool result = false;
if (index >= 0 && index < fNumClauses) {
result = true;
clause *clause = &fClauses[index];
if (start)
*start = clause->start;
if (end)
*end = clause->end;
}
return result;
}
int32
InlineInput::CountClauses() const
{
return fNumClauses;
}
void
InlineInput::ResetClauses()
{
fNumClauses = 0;
free(fClauses);
fClauses = NULL;
}
+55
View File
@@ -0,0 +1,55 @@
/*
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
*/
#ifndef __INLINEINPUT_H
#define __INLINEINPUT_H
#include <Messenger.h>
#include <String.h>
struct clause;
class InlineInput {
public:
InlineInput(BMessenger);
~InlineInput();
const BMessenger *Method() const;
const char *String() const;
void SetString(const char *string);
bool IsActive() const;
void SetActive(bool active);
int32 SelectionLength() const;
void SetSelectionLength(int32);
int32 SelectionOffset() const;
void SetSelectionOffset(int32 offset);
bool AddClause(int32, int32);
bool GetClause(int32 index, int32 *start, int32 *end) const;
int32 CountClauses() const;
void ResetClauses();
private:
const BMessenger fMessenger;
BString fString;
bool fActive;
int32 fSelectionOffset;
int32 fSelectionLength;
int32 fNumClauses;
clause *fClauses;
};
#endif //__INLINEINPUT_H
+1
View File
@@ -13,6 +13,7 @@ Application Terminal :
FindWindow.cpp
Globals.cpp
HistoryBuffer.cpp
InlineInput.cpp
PrefHandler.cpp
PrefWindow.cpp
Shell.cpp
+3 -9
View File
@@ -226,19 +226,13 @@ Shell::FD() const
}
void
status_t
Shell::AttachBuffer(TerminalBuffer *buffer)
{
if (fAttached)
return;
return B_ERROR;
status_t status = fTermParse->StartThreads(buffer);
if (status < B_OK) {
// TODO: What can we do here ?
fprintf(stderr, "Shell:AttachBuffer():"
" cannot start parser threads: %s",
strerror(status));
}
return fTermParse->StartThreads(buffer);
}
+1 -1
View File
@@ -40,7 +40,7 @@ public:
int FD() const;
pid_t ProcessID() const { return fProcessID; }
virtual void AttachBuffer(TerminalBuffer *buffer);
virtual status_t AttachBuffer(TerminalBuffer *buffer);
virtual void DetachBuffer();
private:
+6
View File
@@ -24,6 +24,12 @@ public:
uint32 flags = B_FULL_UPDATE_ON_RESIZE
| B_WILL_DRAW | B_NAVIGABLE_JUMP
| B_FRAME_EVENTS | B_NAVIGABLE);
SmartTabView(const char* name,
button_width width = B_WIDTH_AS_USUAL,
uint32 flags = B_FULL_UPDATE_ON_RESIZE
| B_WILL_DRAW | B_NAVIGABLE_JUMP
| B_FRAME_EVENTS | B_NAVIGABLE
| B_SUPPORTS_LAYOUT);
virtual ~SmartTabView();
void SetInsets(float left, float top, float right,
+1 -1
View File
@@ -31,7 +31,7 @@
#ifndef TERMCONST_H_INCLUDED
#define TERMCONST_H_INCLUDED
// Application signature (Must same in Muterminal.rsrc)
// Application signature (Must same in Terminal.rdef)
#define TERM_SIGNATURE "application/x-vnd.Haiku-Terminal"
#define PREFFILE_MIMETYPE "text/x-terminal-pref"
+219 -32
View File
@@ -26,6 +26,7 @@
#include <new>
#include <Alert.h>
#include <Application.h>
#include <Beep.h>
#include <Clipboard.h>
#include <Debug.h>
@@ -48,6 +49,7 @@
#include <Window.h>
#include "CodeConv.h"
#include "InlineInput.h"
#include "Shell.h"
#include "TermConst.h"
#include "TerminalBuffer.h"
@@ -229,9 +231,6 @@ TermView::TermView(BMessage* archive)
fReportButtonMouseEvent(false),
fReportAnyMouseEvent(false)
{
SetFlags(Flags() | B_WILL_DRAW | B_FRAME_EVENTS
| B_FULL_UPDATE_ON_RESIZE);
BRect frame = Bounds();
if (archive->FindInt32("encoding", (int32*)&fEncoding) < B_OK)
@@ -270,6 +269,9 @@ TermView::TermView(BMessage* archive)
status_t
TermView::_InitObject(int32 argc, const char** argv)
{
SetFlags(Flags() | B_WILL_DRAW | B_FRAME_EVENTS
| B_FULL_UPDATE_ON_RESIZE/* | B_INPUT_METHOD_AWARE*/);
fShell = NULL;
fWinchRunner = NULL;
fCursorBlinkRunner = NULL;
@@ -793,9 +795,8 @@ TermView::_AttachShell(Shell *shell)
return B_BAD_VALUE;
fShell = shell;
fShell->AttachBuffer(TextBuffer());
return B_OK;
return fShell->AttachBuffer(TextBuffer());
}
@@ -823,7 +824,6 @@ TermView::_Activate()
void
TermView::_Deactivate()
{
// DoIMConfirm();
// make sure the cursor becomes visible
fCursorState = 0;
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
@@ -955,6 +955,9 @@ void
TermView::_BlinkCursor()
{
bool wasVisible = _IsCursorVisible();
if (!wasVisible && fInline && fInline->IsActive())
return;
bigtime_t now = system_time();
if (Window()->IsActive() && now - fLastActivityTime >= kCursorBlinkInterval)
@@ -1138,6 +1141,9 @@ TermView::Draw(BRect updateRect)
}
}
if (fInline && fInline->IsActive())
_DrawInlineMethodString();
if (fCursor >= TermPos(x1, y1) && fCursor <= TermPos(x2, y2))
_DrawCursor();
}
@@ -1565,35 +1571,49 @@ TermView::MessageReceived(BMessage *msg)
}
break;
}
case B_INPUT_METHOD_EVENT:
{
int32 opcode;
if (msg->FindInt32("be:opcode", &opcode) == B_OK) {
switch (opcode) {
case B_INPUT_METHOD_STARTED:
{
BMessenger messenger;
if (msg->FindMessenger("be:reply_to",
&messenger) == B_OK) {
fInline = new (std::nothrow)
InlineInput(messenger);
}
break;
}
case B_INPUT_METHOD_STOPPED:
delete fInline;
fInline = NULL;
break;
case B_INPUT_METHOD_CHANGED:
if (fInline != NULL)
_HandleInputMethodChanged(msg);
break;
case B_INPUT_METHOD_LOCATION_REQUEST:
if (fInline != NULL)
_HandleInputMethodLocationRequest();
break;
default:
break;
}
}
break;
}
case MENU_CLEAR_ALL:
Clear();
fShell->Write(ctrl_l, 1);
break;
// case B_INPUT_METHOD_EVENT:
// {
// int32 op;
// msg->FindInt32("be:opcode", &op);
// switch (op){
// case B_INPUT_METHOD_STARTED:
//DoIMStart(msg);
// break;
// case B_INPUT_METHOD_STOPPED:
// DoIMStop(msg);
// break;
// case B_INPUT_METHOD_CHANGED:
// DoIMChange(msg);
// break;
// case B_INPUT_METHOD_LOCATION_REQUEST:
// DoIMLocation(msg);
// break;
// }
// }
case kBlinkCursor:
_BlinkCursor();
break;
@@ -1726,7 +1746,7 @@ TermView::TargetedByScrollView(BScrollView *scrollView)
{
BView::TargetedByScrollView(scrollView);
SetScrollBar(scrollView->ScrollBar(B_VERTICAL));
SetScrollBar(scrollView ? scrollView->ScrollBar(B_VERTICAL) : NULL);
}
@@ -2779,9 +2799,176 @@ TermView::_ScrollToRange(TermPos start, TermPos end)
}
}
void
TermView::DisableResizeView(int32 disableCount)
{
fResizeViewDisableCount += disableCount;
}
void
TermView::_DrawInlineMethodString()
{
if (!fInline->String())
return;
const int32 numChars = BString(fInline->String()).CountChars();
BPoint startPoint = _ConvertFromTerminal(fCursor);
BPoint endPoint = startPoint;
endPoint.x += fFontWidth * numChars;
endPoint.y += fFontHeight + 1;
BRect eraseRect(startPoint, endPoint);
PushState();
SetHighColor(kTermColorTable[7]);
FillRect(eraseRect);
PopState();
BPoint loc = _ConvertFromTerminal(fCursor);
loc.y += fFontHeight;
SetFont(&fHalfFont);
SetHighColor(kTermColorTable[0]);
SetLowColor(kTermColorTable[7]);
DrawString(fInline->String(), loc);
}
void
TermView::_HandleInputMethodChanged(BMessage *message)
{
const char *string = NULL;
if (message->FindString("be:string", &string) < B_OK || string == NULL)
return;
_ActivateCursor(false);
if (IsFocus())
be_app->ObscureCursor();
// If we find the "be:confirmed" boolean (and the boolean is true),
// it means it's over for now, so the current InlineInput object
// should become inactive. We will probably receive a
// B_INPUT_METHOD_STOPPED message after this one.
bool confirmed;
if (message->FindBool("be:confirmed", &confirmed) != B_OK)
confirmed = false;
fInline->SetString("");
Invalidate();
// TODO: Debug only
snooze(100000);
fInline->SetString(string);
fInline->ResetClauses();
if (!confirmed && !fInline->IsActive())
fInline->SetActive(true);
// Get the clauses, and pass them to the InlineInput object
// TODO: Find out if what we did it's ok, currently we don't consider
// clauses at all, while the bebook says we should; though the visual
// effect we obtained seems correct. Weird.
int32 clauseCount = 0;
int32 clauseStart;
int32 clauseEnd;
while (message->FindInt32("be:clause_start", clauseCount, &clauseStart)
== B_OK
&& message->FindInt32("be:clause_end", clauseCount, &clauseEnd)
== B_OK) {
if (!fInline->AddClause(clauseStart, clauseEnd))
break;
clauseCount++;
}
if (confirmed) {
fInline->SetString("");
_ActivateCursor(true);
// now we need to feed ourselves the individual characters as if the
// user would have pressed them now - this lets KeyDown() pick out all
// the special characters like B_BACKSPACE, cursor keys and the like:
const char* currPos = string;
const char* prevPos = currPos;
while (*currPos != '\0') {
if ((*currPos & 0xC0) == 0xC0) {
// found the start of an UTF-8 char, we collect while it lasts
++currPos;
while ((*currPos & 0xC0) == 0x80)
++currPos;
} else if ((*currPos & 0xC0) == 0x80) {
// illegal: character starts with utf-8 intermediate byte, skip it
prevPos = ++currPos;
} else {
// single byte character/code, just feed that
++currPos;
}
KeyDown(prevPos, currPos - prevPos);
prevPos = currPos;
}
Invalidate();
} else {
// temporarily show transient state of inline input
int32 selectionStart = 0;
int32 selectionEnd = 0;
message->FindInt32("be:selection", 0, &selectionStart);
message->FindInt32("be:selection", 1, &selectionEnd);
fInline->SetSelectionOffset(selectionStart);
fInline->SetSelectionLength(selectionEnd - selectionStart);
Invalidate();
}
}
void
TermView::_HandleInputMethodLocationRequest()
{
BMessage message(B_INPUT_METHOD_EVENT);
message.AddInt32("be:opcode", B_INPUT_METHOD_LOCATION_REQUEST);
BString string(fInline->String());
const int32 &limit = string.CountChars();
BPoint where = _ConvertFromTerminal(fCursor);
where.y += fFontHeight;
for (int32 i = 0; i < limit; i++) {
// Add the location of the UTF8 characters
where.x += fFontWidth;
ConvertToScreen(&where);
message.AddPoint("be:location_reply", where);
message.AddFloat("be:height_reply", fFontHeight);
}
fInline->Method()->SendMessage(&message);
}
void
TermView::_CancelInputMethod()
{
if (!fInline)
return;
InlineInput *inlineInput = fInline;
fInline = NULL;
if (inlineInput->IsActive() && Window()) {
Invalidate();
BMessage message(B_INPUT_METHOD_EVENT);
message.AddInt32("be:opcode", B_INPUT_METHOD_STOPPED);
inlineInput->Method()->SendMessage(&message);
}
delete inlineInput;
}
+8
View File
@@ -26,6 +26,7 @@ class BScrollView;
class BString;
class BStringView;
class BasicTerminalBuffer;
class InlineInput;
class ResizeWindow;
class TermBuffer;
class TerminalBuffer;
@@ -183,6 +184,11 @@ private:
void _SendMouseEvent(int32 button, int32 mode, int32 x,
int32 y, bool motion);
void _DrawInlineMethodString();
void _HandleInputMethodChanged(BMessage* message);
void _HandleInputMethodLocationRequest();
void _CancelInputMethod();
private:
class CharClassifier;
@@ -222,10 +228,12 @@ private:
int fEncoding;
bool fActive;
// Object pointer.
TerminalBuffer* fTextBuffer;
BasicTerminalBuffer* fVisibleTextBuffer;
BScrollBar* fScrollBar;
InlineInput* fInline;
// Color and Attribute.
rgb_color fTextForeColor;
+40 -31
View File
@@ -9,6 +9,7 @@
#include "TermWindow.h"
#include <new>
#include <stdio.h>
#include <string.h>
#include <time.h>
@@ -228,13 +229,14 @@ TermWindow::_InitWindow()
void
TermWindow::MenusBeginning()
{
TermView *view = _ActiveTermView();
// Syncronize Encode Menu Pop-up menu and Preference.
BMenuItem *item = fEncodingmenu->FindItem(EncodingAsString(_ActiveTermView()->Encoding()));
BMenuItem *item = fEncodingmenu->FindItem(
EncodingAsString(view->Encoding()));
if (item != NULL)
item->SetMarked(true);
TermView *view = _ActiveTermView();
BFont font;
view->GetTermFont(&font);
@@ -248,23 +250,28 @@ TermWindow::MenusBeginning()
/* static */
void
TermWindow::_MakeEncodingMenu(BMenu *eMenu, bool withShortcuts)
BMenu *
TermWindow::_MakeEncodingMenu()
{
BMenu *menu = new (std::nothrow) BMenu("Text Encoding");
if (menu == NULL)
return NULL;
int encoding;
int i = 0;
while (get_nth_encoding(i, &encoding) == B_OK) {
BMessage *msg = new BMessage(MENU_ENCODING);
msg->AddInt32("op", (int32)encoding);
if (withShortcuts) {
eMenu->AddItem(new BMenuItem(EncodingAsString(encoding),
msg, id2shortcut(encoding)));
} else
eMenu->AddItem(new BMenuItem(EncodingAsString(encoding),
msg));
while (get_next_encoding(i, &encoding) == B_OK) {
BMessage *message = new BMessage(MENU_ENCODING);
if (message != NULL) {
message->AddInt32("op", (int32)encoding);
menu->AddItem(new BMenuItem(EncodingAsString(encoding),
message));
}
i++;
}
menu->SetRadioMode(true);
return menu;
}
@@ -321,12 +328,9 @@ TermWindow::_SetupMenu()
// Make Help Menu.
fHelpmenu = new BMenu("Settings");
fWindowSizeMenu = new BMenu("Window Size");
_BuildWindowSizeMenu(fWindowSizeMenu);
fWindowSizeMenu = _MakeWindowSizeMenu();
fEncodingmenu = new BMenu("Text Encoding");
fEncodingmenu->SetRadioMode(true);
_MakeEncodingMenu(fEncodingmenu, false);
fEncodingmenu = _MakeEncodingMenu();
fSizeMenu = new BMenu("Text Size");
@@ -415,8 +419,10 @@ TermWindow::MessageReceived(BMessage *message)
}
case MENU_PREF_OPEN:
if (!fPrefWindow)
if (!fPrefWindow) {
fPrefWindow = new PrefWindow(this);
//fPrefWindow->
}
else
fPrefWindow->Activate();
break;
@@ -427,12 +433,8 @@ TermWindow::MessageReceived(BMessage *message)
case MENU_FIND_STRING:
if (!fFindPanel) {
BRect r = Frame();
r.left += 20;
r.top += 20;
r.right = r.left + 260;
r.bottom = r.top + 190;
fFindPanel = new FindWindow(r, this, fFindString, fFindSelection, fMatchWord, fMatchCase, fForwardSearch);
fFindPanel = new FindWindow(this, fFindString, fFindSelection,
fMatchWord, fMatchCase, fForwardSearch);
}
else
fFindPanel->Activate();
@@ -970,16 +972,21 @@ TermWindow::_ResizeView(TermView *view)
}
void
TermWindow::_BuildWindowSizeMenu(BMenu *menu)
/* static */
BMenu*
TermWindow::_MakeWindowSizeMenu()
{
BMenu *menu = new (std::nothrow) BMenu("Window Size");
if (menu == NULL)
return NULL;
const int32 windowSizes[4][2] = {
{ 80, 25 },
{ 80, 40 },
{ 132, 25 },
{ 132, 40 }
};
};
const int32 sizeNum = sizeof(windowSizes) / sizeof(windowSizes[0]);
for (int32 i = 0; i < sizeNum; i++) {
char label[32];
@@ -995,6 +1002,8 @@ TermWindow::_BuildWindowSizeMenu(BMenu *menu)
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Fullscreen", new BMessage(FULLSCREEN),
B_ENTER));
return menu;
}
+4 -2
View File
@@ -70,7 +70,9 @@ private:
void _SetTermColors(TermViewContainerView *termView);
void _InitWindow();
void _SetupMenu();
static void _MakeEncodingMenu(BMenu *eMenu, bool withShortcuts);
static BMenu* _MakeEncodingMenu();
static BMenu* _MakeWindowSizeMenu();
void _GetPreferredFont(BFont &font);
status_t _DoPageSetup();
void _DoPrint();
@@ -83,7 +85,7 @@ private:
int32 _IndexOfTermView(TermView* termView) const;
void _CheckChildren();
void _ResizeView(TermView *view);
void _BuildWindowSizeMenu(BMenu *menu);
int32 _NewSessionID();
BString fInitialTitle;