* The shortcuts of the encodings shadowed other shortcuts, like Command-G to

switch Terminals. I've not only removed that shortcut, though, I disabled
  all encoding shortcuts, as I frankly don't see any use for them beyond
  confusing users (by accidently hitting one of the 134 shortcuts).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29494 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-03-13 20:00:01 +00:00
parent d39c5354b8
commit a41b1bcb3a
5 changed files with 74 additions and 57 deletions

View File

@ -1,6 +1,13 @@
/*
* Copyright 2003-2009 Haiku, Inc.
* Distributed under the terms of the MIT license.
*/
#include "Coding.h" #include "Coding.h"
#include <string.h> #include <string.h>
struct etable { struct etable {
const char *name; // long name for menu item. const char *name; // long name for menu item.
const char *shortname; // short name (use for command-line etc.) const char *shortname; // short name (use for command-line etc.)
@ -8,12 +15,10 @@ struct etable {
const int32 id; // encoding id const int32 id; // encoding id
}; };
/* /*
* encoding_table ... use encoding menu, message, and preference keys. * encoding_table ... use encoding menu, message, and preference keys.
*/ */
const static etable kEncodingTable[] = const static etable kEncodingTable[] = {
{
{"UTF-8", "UTF8", 'U', M_UTF8}, {"UTF-8", "UTF8", 'U', M_UTF8},
{"ISO-8859-1", "8859-1", '1', B_ISO1_CONVERSION}, {"ISO-8859-1", "8859-1", '1', B_ISO1_CONVERSION},
{"ISO-8859-2", "8859-2", '2', B_ISO2_CONVERSION}, {"ISO-8859-2", "8859-2", '2', B_ISO2_CONVERSION},
@ -30,7 +35,7 @@ const static etable kEncodingTable[] =
{"Shift-JIS", "SJIS", 'S', B_SJIS_CONVERSION}, {"Shift-JIS", "SJIS", 'S', B_SJIS_CONVERSION},
{"EUC-jp", "EUCJ", 'E', B_EUC_CONVERSION}, {"EUC-jp", "EUCJ", 'E', B_EUC_CONVERSION},
{"EUC-kr", "EUCK", 'K', B_EUC_KR_CONVERSION}, {"EUC-kr", "EUCK", 'K', B_EUC_KR_CONVERSION},
{"GB18030", "GB18030", 'G', B_GBK_CONVERSION}, {"GB18030", "GB18030", 0, B_GBK_CONVERSION},
{"Big5", "Big5", 'B', B_BIG5_CONVERSION}, {"Big5", "Big5", 'B', B_BIG5_CONVERSION},
/* Not Implemented. /* Not Implemented.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2005, Haiku, Inc. * Copyright (c) 2001-2009, Haiku, Inc.
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net> * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
* 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.
@ -7,19 +7,21 @@
* Authors: * Authors:
* Kian Duffy <myob@users.sourceforge.net> * Kian Duffy <myob@users.sourceforge.net>
*/ */
#include <Menu.h>
#include <string.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <Font.h>
#include <stdio.h>
#include "MenuUtil.h" #include "MenuUtil.h"
#include "TermConst.h"
#include "PrefHandler.h"
#include "Coding.h"
//#define LOCALE_FILE_DIR PREF_FOLDER"menu/" #include <stdio.h>
#include <string.h>
#include <Font.h>
#include <Menu.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include "Coding.h"
#include "PrefHandler.h"
#include "TermConst.h"
BPopUpMenu * BPopUpMenu *
MakeMenu(ulong msg, const char **items, const char *defaultItemName) MakeMenu(ulong msg, const char **items, const char *defaultItemName)
@ -42,24 +44,25 @@ MakeMenu(ulong msg, const char **items, const char *defaultItemName)
} }
void void
MakeEncodingMenu(BMenu *eMenu, bool flag) MakeEncodingMenu(BMenu *eMenu, bool withShortcuts)
{ {
int encoding; int encoding;
int i = 0; int i = 0;
while (get_nth_encoding(i, &encoding) == B_OK) { while (get_nth_encoding(i, &encoding) == B_OK) {
BMessage *msg = new BMessage(MENU_ENCODING); BMessage *msg = new BMessage(MENU_ENCODING);
msg->AddInt32("op", (int32)encoding); msg->AddInt32("op", (int32)encoding);
if (flag) if (withShortcuts) {
eMenu->AddItem(new BMenuItem(EncodingAsString(encoding), msg, id2shortcut(encoding))); eMenu->AddItem(new BMenuItem(EncodingAsString(encoding), msg,
else id2shortcut(encoding)));
} else
eMenu->AddItem(new BMenuItem(EncodingAsString(encoding), msg)); eMenu->AddItem(new BMenuItem(EncodingAsString(encoding), msg));
i++; i++;
} }
} }
void void
LoadLocaleFile(PrefHandler *pref) LoadLocaleFile(PrefHandler *pref)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2005, Haiku, Inc. * Copyright (c) 2001-2009, Haiku, Inc.
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net> * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
* 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.
@ -7,8 +7,8 @@
* Authors: * Authors:
* Kian Duffy <myob@users.sourceforge.net> * Kian Duffy <myob@users.sourceforge.net>
*/ */
#ifndef MENUUTIL_H_INCLUDED #ifndef MENU_UTIL_H
#define MENUUTIL_H_INCLUDED #define MENU_UTIL_H
#include <SupportDefs.h> #include <SupportDefs.h>
@ -19,10 +19,7 @@ class PrefHandler;
BPopUpMenu* MakeMenu(ulong msg, const char** items, BPopUpMenu* MakeMenu(ulong msg, const char** items,
const char* defaultItemName); const char* defaultItemName);
void MakeEncodingMenu(BMenu *eMenu, bool withShortcuts);
void LoadLocaleFile(PrefHandler* handler);
void MakeEncodingMenu(BMenu *eMenu, bool flag); #endif // MENU_UTIL_H
void LoadLocaleFile (PrefHandler *);
#endif

View File

@ -295,10 +295,12 @@ TermApp::_SwitchTerm()
bool bool
TermApp::_IsSwitchTarget(team_id id) TermApp::_IsSwitchTarget(team_id id)
{ {
uint32 currentWorkspace = 1L << current_workspace();
BMessenger app(TERM_SIGNATURE, id); BMessenger app(TERM_SIGNATURE, id);
if (app.IsTargetLocal()) { if (app.IsTargetLocal()) {
return !fTermWindow->IsMinimized() return !fTermWindow->IsMinimized()
&& (fTermWindow->Workspaces() & (1L << current_workspace())) != 0; && (fTermWindow->Workspaces() & currentWorkspace) != 0;
} }
BMessage reply; BMessage reply;
@ -311,13 +313,11 @@ TermApp::_IsSwitchTarget(team_id id)
|| reply.FindInt32("workspaces", &workspaces) != B_OK) || reply.FindInt32("workspaces", &workspaces) != B_OK)
return false; return false;
return !minimized return !minimized && (workspaces & currentWorkspace) != 0;
&& (workspaces & (1L << current_workspace())) != 0;
} }
/*! /*! Checks if all teams that have an ID-to-team mapping in the message
Checks if all teams that have an ID-to-team mapping in the message
are still running. are still running.
The IDs for teams that are gone will be made available again, and The IDs for teams that are gone will be made available again, and
their mapping is removed from the message. their mapping is removed from the message.

View File

@ -250,17 +250,22 @@ TermWindow::_SetupMenu()
// Make File Menu. // Make File Menu.
fFilemenu = new BMenu("Terminal"); fFilemenu = new BMenu("Terminal");
fFilemenu->AddItem(new BMenuItem("Switch Terminals", new BMessage(MENU_SWITCH_TERM),'G')); fFilemenu->AddItem(new BMenuItem("Switch Terminals",
fFilemenu->AddItem(new BMenuItem("New Terminal" B_UTF8_ELLIPSIS, new BMessage(MENU_NEW_TERM), 'N')); new BMessage(MENU_SWITCH_TERM),'G'));
fFilemenu->AddItem(new BMenuItem("New Terminal" B_UTF8_ELLIPSIS,
new BMessage(MENU_NEW_TERM), 'N'));
fFilemenu->AddItem(new BMenuItem("New Tab", new BMessage(kNewTab), 'T')); fFilemenu->AddItem(new BMenuItem("New Tab", new BMessage(kNewTab), 'T'));
fFilemenu->AddSeparatorItem(); fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("Page Setup" B_UTF8_ELLIPSIS, new BMessage(MENU_PAGE_SETUP))); fFilemenu->AddItem(new BMenuItem("Page Setup" B_UTF8_ELLIPSIS,
new BMessage(MENU_PAGE_SETUP)));
fFilemenu->AddItem(new BMenuItem("Print", new BMessage(MENU_PRINT),'P')); fFilemenu->AddItem(new BMenuItem("Print", new BMessage(MENU_PRINT),'P'));
fFilemenu->AddSeparatorItem(); fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("About Terminal" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); fFilemenu->AddItem(new BMenuItem("About Terminal" B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED)));
fFilemenu->AddSeparatorItem(); fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); fFilemenu->AddItem(new BMenuItem("Quit",
new BMessage(B_QUIT_REQUESTED), 'Q'));
fMenubar->AddItem(fFilemenu); fMenubar->AddItem(fFilemenu);
// Make Edit Menu. // Make Edit Menu.
@ -268,14 +273,19 @@ TermWindow::_SetupMenu()
fEditmenu->AddItem(new BMenuItem("Copy", new BMessage(B_COPY),'C')); fEditmenu->AddItem(new BMenuItem("Copy", new BMessage(B_COPY),'C'));
fEditmenu->AddItem(new BMenuItem("Paste", new BMessage(B_PASTE),'V')); fEditmenu->AddItem(new BMenuItem("Paste", new BMessage(B_PASTE),'V'));
fEditmenu->AddSeparatorItem(); fEditmenu->AddSeparatorItem();
fEditmenu->AddItem (new BMenuItem ("Select All", new BMessage (B_SELECT_ALL), 'A')); fEditmenu->AddItem(new BMenuItem("Select All",
fEditmenu->AddItem (new BMenuItem ("Clear All", new BMessage (MENU_CLEAR_ALL), 'L')); new BMessage(B_SELECT_ALL), 'A'));
fEditmenu->AddItem(new BMenuItem("Clear All",
new BMessage(MENU_CLEAR_ALL), 'L'));
fEditmenu->AddSeparatorItem(); fEditmenu->AddSeparatorItem();
fEditmenu->AddItem (new BMenuItem ("Find" B_UTF8_ELLIPSIS, new BMessage (MENU_FIND_STRING),'F')); fEditmenu->AddItem(new BMenuItem("Find" B_UTF8_ELLIPSIS,
fFindBackwardMenuItem = new BMenuItem ("Find Backward", new BMessage (MENU_FIND_BACKWARD), '['); new BMessage(MENU_FIND_STRING),'F'));
fFindBackwardMenuItem = new BMenuItem("Find Backward",
new BMessage(MENU_FIND_BACKWARD), '[');
fEditmenu->AddItem(fFindBackwardMenuItem); fEditmenu->AddItem(fFindBackwardMenuItem);
fFindBackwardMenuItem->SetEnabled(false); fFindBackwardMenuItem->SetEnabled(false);
fFindForwardMenuItem = new BMenuItem ("Find Forward", new BMessage (MENU_FIND_FORWARD), ']'); fFindForwardMenuItem = new BMenuItem("Find Forward",
new BMessage(MENU_FIND_FORWARD), ']');
fEditmenu->AddItem(fFindForwardMenuItem); fEditmenu->AddItem(fFindForwardMenuItem);
fFindForwardMenuItem->SetEnabled(false); fFindForwardMenuItem->SetEnabled(false);
@ -288,13 +298,15 @@ TermWindow::_SetupMenu()
fEncodingmenu = new BMenu("Text Encoding"); fEncodingmenu = new BMenu("Text Encoding");
fEncodingmenu->SetRadioMode(true); fEncodingmenu->SetRadioMode(true);
MakeEncodingMenu(fEncodingmenu, true); MakeEncodingMenu(fEncodingmenu, false);
fHelpmenu->AddItem(fWindowSizeMenu); fHelpmenu->AddItem(fWindowSizeMenu);
fHelpmenu->AddItem(fEncodingmenu); fHelpmenu->AddItem(fEncodingmenu);
fHelpmenu->AddSeparatorItem(); fHelpmenu->AddSeparatorItem();
fHelpmenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(MENU_PREF_OPEN))); fHelpmenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS,
new BMessage(MENU_PREF_OPEN)));
fHelpmenu->AddSeparatorItem(); fHelpmenu->AddSeparatorItem();
fHelpmenu->AddItem(new BMenuItem("Save as default", new BMessage(SAVE_AS_DEFAULT))); fHelpmenu->AddItem(new BMenuItem("Save as default",
new BMessage(SAVE_AS_DEFAULT)));
fMenubar->AddItem(fHelpmenu); fMenubar->AddItem(fHelpmenu);
AddChild(fMenubar); AddChild(fMenubar);