mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
[qwaq] Add a key event listener to Editor
This will allow for easy expansion of editor functionality without messing with the editor itself. In particularly, an editor normally doesn't need to know anything about debugger hot keys.
This commit is contained in:
parent
d96059c70e
commit
16bd047022
2 changed files with 22 additions and 0 deletions
|
@ -4,7 +4,15 @@
|
||||||
#include "qwaq-editbuffer.h"
|
#include "qwaq-editbuffer.h"
|
||||||
#include "qwaq-view.h"
|
#include "qwaq-view.h"
|
||||||
|
|
||||||
|
@class Editor;
|
||||||
@class EditBuffer;
|
@class EditBuffer;
|
||||||
|
@class ListenerGroup;
|
||||||
|
|
||||||
|
// Data sent to onKeyEvent listeners
|
||||||
|
typedef struct ed_event_s {
|
||||||
|
Editor *editor;
|
||||||
|
struct qwaq_event_s *event;
|
||||||
|
} ed_event_t;
|
||||||
|
|
||||||
@interface Editor : View
|
@interface Editor : View
|
||||||
{
|
{
|
||||||
|
@ -19,8 +27,11 @@
|
||||||
Point cursor;
|
Point cursor;
|
||||||
unsigned line_count;
|
unsigned line_count;
|
||||||
string filename;
|
string filename;
|
||||||
|
ListenerGroup *onEvent;
|
||||||
|
ed_event_t _event;
|
||||||
}
|
}
|
||||||
-initWithRect:(Rect) rect file:(string) filename;
|
-initWithRect:(Rect) rect file:(string) filename;
|
||||||
|
-(ListenerGroup *)onEvent;
|
||||||
-(string)filename;
|
-(string)filename;
|
||||||
-scrollUp:(unsigned) count;
|
-scrollUp:(unsigned) count;
|
||||||
-scrollDown:(unsigned) count;
|
-scrollDown:(unsigned) count;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <QF/keys.h>
|
#include <QF/keys.h>
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "qwaq-editor.h"
|
#include "qwaq-editor.h"
|
||||||
|
#include "qwaq-listener.h"
|
||||||
|
|
||||||
@implementation Editor
|
@implementation Editor
|
||||||
|
|
||||||
|
@ -15,9 +16,15 @@
|
||||||
linebuffer = [DrawBuffer buffer: { xlen, 1 }];
|
linebuffer = [DrawBuffer buffer: { xlen, 1 }];
|
||||||
growMode = gfGrowHi;
|
growMode = gfGrowHi;
|
||||||
options = ofCanFocus;
|
options = ofCanFocus;
|
||||||
|
onEvent = [[ListenerGroup alloc] init];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(ListenerGroup *)onEvent
|
||||||
|
{
|
||||||
|
return onEvent;
|
||||||
|
}
|
||||||
|
|
||||||
-(string)filename
|
-(string)filename
|
||||||
{
|
{
|
||||||
return filename;
|
return filename;
|
||||||
|
@ -46,6 +53,10 @@
|
||||||
|
|
||||||
-handleEvent:(qwaq_event_t *) event
|
-handleEvent:(qwaq_event_t *) event
|
||||||
{
|
{
|
||||||
|
// give any listeners a chance to override or extend event handling
|
||||||
|
_event.editor = self;
|
||||||
|
_event.event = event;
|
||||||
|
[onEvent respond: &_event];
|
||||||
if (event.what & qe_mouse) {
|
if (event.what & qe_mouse) {
|
||||||
if (event.what == qe_mouseclick) {
|
if (event.what == qe_mouseclick) {
|
||||||
if (event.mouse.buttons & (1 << 3)) {
|
if (event.mouse.buttons & (1 << 3)) {
|
||||||
|
|
Loading…
Reference in a new issue