2010-05-07 04:47:10 -05:00
|
|
|
/*
|
2011-12-03 16:38:03 -06:00
|
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
2010-05-07 04:47:10 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Andrea Anzani, andrea.anzani@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <InterfaceDefs.h>
|
|
|
|
#include <Message.h>
|
|
|
|
#include <Window.h>
|
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
#include "AppMessages.h"
|
2010-05-07 04:47:10 -05:00
|
|
|
#include "EditingFilter.h"
|
|
|
|
|
|
|
|
|
|
|
|
EditingFilter::EditingFilter(BTextView* view)
|
2010-05-19 17:28:26 -05:00
|
|
|
:
|
|
|
|
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN, NULL),
|
2010-05-20 16:31:55 -05:00
|
|
|
fView(view)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
filter_result
|
|
|
|
EditingFilter::Filter(BMessage* message, BHandler** target)
|
|
|
|
{
|
|
|
|
int32 modifiers;
|
|
|
|
|
|
|
|
int8 byte;
|
|
|
|
message->FindInt8("byte", &byte);
|
|
|
|
|
|
|
|
// If we have modifiers but none are the Alt key
|
|
|
|
if (message->FindInt32("modifiers", &modifiers))
|
|
|
|
return B_DISPATCH_MESSAGE;
|
|
|
|
|
|
|
|
// If the Alt key jives with the command_enter status
|
|
|
|
if ((modifiers & B_COMMAND_KEY) != 0 && byte == B_ENTER) {
|
2010-05-20 16:31:55 -05:00
|
|
|
fView->Insert("\n");
|
2010-05-07 04:47:10 -05:00
|
|
|
return B_SKIP_MESSAGE;
|
|
|
|
} else if ((modifiers & B_COMMAND_KEY) == 0 && byte == B_ENTER) {
|
2021-06-20 12:44:20 -05:00
|
|
|
fView->Window()->PostMessage(APP_CHAT);
|
2010-05-07 04:47:10 -05:00
|
|
|
return B_SKIP_MESSAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return B_DISPATCH_MESSAGE;
|
|
|
|
}
|