Keymap: Change GetModifiedCharacters API to return BStringList.
Simplifies the API and makes ownership semantics clearer. Change-Id: I59d2e3ef8055253e85943500fb65356762055c54 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8914 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
3e245f7b20
commit
007126ed6f
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <ObjectList.h>
|
||||
#include <StringList.h>
|
||||
|
||||
|
||||
class BKeymap {
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
int32* numBytes) const;
|
||||
status_t GetModifiedCharacters(const char* in,
|
||||
int32 inModifiers, int32 outModifiers,
|
||||
BObjectList<const char>* _outList);
|
||||
BStringList& _outList);
|
||||
|
||||
const key_map& Map() const { return fKeys; }
|
||||
|
||||
|
||||
@@ -561,12 +561,12 @@ TermWindow::_SetupMenu()
|
||||
|
||||
BKeymap keymap;
|
||||
keymap.SetToCurrent();
|
||||
BObjectList<const char> unmodified(3, true);
|
||||
if (keymap.GetModifiedCharacters("+", B_SHIFT_KEY, 0, &unmodified)
|
||||
BStringList unmodified(3);
|
||||
if (keymap.GetModifiedCharacters("+", B_SHIFT_KEY, 0, unmodified)
|
||||
== B_OK) {
|
||||
int32 count = unmodified.CountItems();
|
||||
int32 count = unmodified.CountStrings();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
uint32 key = BUnicodeChar::FromUTF8(unmodified.ItemAt(i));
|
||||
uint32 key = BUnicodeChar::FromUTF8(unmodified.StringAt(i));
|
||||
if (!HasShortcut(key, 0)) {
|
||||
// Add semantic + shortcut, bug #7428
|
||||
AddShortcut(key, B_COMMAND_KEY,
|
||||
|
||||
@@ -687,12 +687,12 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
|
||||
|
||||
BKeymap keymap;
|
||||
keymap.SetToCurrent();
|
||||
BObjectList<const char> unmodified(3, true);
|
||||
if (keymap.GetModifiedCharacters("+", B_SHIFT_KEY, 0, &unmodified)
|
||||
BStringList unmodified(3);
|
||||
if (keymap.GetModifiedCharacters("+", B_SHIFT_KEY, 0, unmodified)
|
||||
== B_OK) {
|
||||
int32 count = unmodified.CountItems();
|
||||
int32 count = unmodified.CountStrings();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
uint32 key = BUnicodeChar::FromUTF8(unmodified.ItemAt(i));
|
||||
uint32 key = BUnicodeChar::FromUTF8(unmodified.StringAt(i));
|
||||
if (!HasShortcut(key, 0)) {
|
||||
// Add semantic zoom in shortcut, bug #7428
|
||||
AddShortcut(key, B_COMMAND_KEY,
|
||||
|
||||
@@ -455,9 +455,9 @@ BKeymap::GetChars(uint32 keyCode, uint32 modifiers, uint8 activeDeadKey,
|
||||
*/
|
||||
status_t
|
||||
BKeymap::GetModifiedCharacters(const char* in, int32 inModifiers,
|
||||
int32 outModifiers, BObjectList<const char>* _outList)
|
||||
int32 outModifiers, BStringList& _outList)
|
||||
{
|
||||
if (in == NULL || *in == '\0' || _outList == NULL)
|
||||
if (in == NULL || *in == '\0')
|
||||
return B_BAD_VALUE;
|
||||
|
||||
for(uint32 i = 0; i < 128; i++) {
|
||||
@@ -470,14 +470,8 @@ BKeymap::GetModifiedCharacters(const char* in, int32 inModifiers,
|
||||
|
||||
int32 outOffset = Offset(i, outModifiers);
|
||||
size_t sizeOut = fChars[outOffset++];
|
||||
char* out = (char*)malloc(sizeOut + 1);
|
||||
if (out == NULL)
|
||||
if (!_outList.Add(BString(fChars + outOffset, sizeOut)))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
memcpy(out, fChars + outOffset, sizeOut);
|
||||
out[sizeOut] = '\0';
|
||||
|
||||
_outList->AddItem((const char*)out);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
|
||||
@@ -792,12 +792,12 @@ BContainerWindow::Init(const BMessage* message)
|
||||
|
||||
BKeymap keymap;
|
||||
if (keymap.SetToCurrent() == B_OK) {
|
||||
BObjectList<const char> unmodified(3, true);
|
||||
if (keymap.GetModifiedCharacters("+", B_SHIFT_KEY, 0, &unmodified)
|
||||
BStringList unmodified(3);
|
||||
if (keymap.GetModifiedCharacters("+", B_SHIFT_KEY, 0, unmodified)
|
||||
== B_OK) {
|
||||
int32 count = unmodified.CountItems();
|
||||
int32 count = unmodified.CountStrings();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
uint32 key = BUnicodeChar::FromUTF8(unmodified.ItemAt(i));
|
||||
uint32 key = BUnicodeChar::FromUTF8(unmodified.StringAt(i));
|
||||
if (!HasShortcut(key, 0)) {
|
||||
// Add semantic zoom in shortcut, bug #6692
|
||||
BMessage* increaseSize = new BMessage(kIconMode);
|
||||
|
||||
Reference in New Issue
Block a user