2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
5 Desc: Code for CONU_SNIPMAP console units.
10 #include <proto/graphics.h>
11 #include <proto/intuition.h>
12 #include <intuition/intuition.h>
14 #include <intuition/imageclass.h>
15 #include <intuition/gadgetclass.h>
16 #include <libraries/gadtools.h>
18 #include <graphics/rastport.h>
19 #include <aros/asmcall.h>
24 #include <aros/debug.h>
26 #include "console_gcc.h"
27 #include "consoleif.h"
31 ULONG start_selection_x
;
32 ULONG start_selection_y
;
39 /*********** SnipMapCon::New() **********************/
41 static Object
*snipmapcon_new(Class
*cl
, Object
*o
, struct opSet
*msg
)
43 EnterFunc(bug("SnipMapCon::New()\n"));
44 o
= (Object
*) DoSuperMethodA(cl
, o
, (Msg
) msg
);
47 struct snipmapdata
*data
= INST_DATA(cl
, o
);
48 memset(data
, 0, sizeof(struct snipmapcondata
));
50 ReturnPtr("SnipMapCon::New", Object
*, o
);
53 /*********** SnipMapCon::Dispose() **************************/
55 static VOID
snipmapcon_dispose(Class
*cl
, Object
*o
, Msg msg
)
57 DoSuperMethodA(cl
, o
, msg
);
60 static VOID
snipmapcon_copy(Class
*cl
, Object
*o
, Msg msg
)
62 /* FIXME: This really should happen here, but currently,
63 charmapcon contains the selection code, and it's hard to
66 DoSuperMethodA(cl
, o
, (Msg
) msg
);
68 /* FIXME: Handle ConClip here */
71 ObtainSemaphore(&ConsoleDevice->copyBufferLock);
72 .. create SGWork and send message to ConClip
73 ReleaseSemaphore(&ConsoleDevice->copyBufferLock);
78 static const STRPTR CONCLIP_PORTNAME
= "ConClip.rendezvous";
80 static VOID
snipmapcon_paste(Class
*cl
, Object
*o
, Msg msg
)
82 struct ConsoleBase
*ConsoleDevice
= (struct ConsoleBase
*)cl
->cl_UserData
;
84 /* if conclip is running, insert <CSI> "0 v" and we're done.
85 * The console.handler will be responsible for the actual paste.
87 if (!IsListEmpty(&ConsoleDevice
->sniphooks
)
88 || FindPort(CONCLIP_PORTNAME
))
90 D(bug("Pasting to ConClip\n"));
91 con_inject(ConsoleDevice
, CU(o
), "\x9b" "0 v", -1);
94 ObtainSemaphore(&ConsoleDevice
->copyBufferLock
);
95 D(bug("Pasting directly (ConClip not found) %p,%d\n",
96 ConsoleDevice
->copyBuffer
, ConsoleDevice
->copyBufferSize
));
97 con_inject(ConsoleDevice
, CU(o
), ConsoleDevice
->copyBuffer
,
98 ConsoleDevice
->copyBufferSize
);
99 ReleaseSemaphore(&ConsoleDevice
->copyBufferLock
);
102 static VOID
snipmapcon_docommand(Class
*cl
, Object
*o
,
103 struct P_Console_DoCommand
*msg
)
105 EnterFunc(IPTR
*params
= msg
->Params
);
107 ("SnipMapCon::DoCommand(o=%p, cmd=%d, params=%p) x=%d, y=%d, ymax=%d\n",
108 o
, msg
->Command
, params
, XCP
, YCP
, CHAR_YMAX(o
)));
110 switch (msg
->Command
)
113 DoSuperMethodA(cl
, o
, (Msg
) msg
);
116 ReturnVoid("SnipMapCon::DoCommand");
119 AROS_UFH3S(IPTR
, dispatch_snipmapconclass
,
120 AROS_UFHA(Class
*, cl
, A0
),
121 AROS_UFHA(Object
*, o
, A2
), AROS_UFHA(Msg
, msg
, A1
))
127 switch (msg
->MethodID
)
130 retval
= (IPTR
) snipmapcon_new(cl
, o
, (struct opSet
*)msg
);
134 snipmapcon_dispose(cl
, o
, msg
);
137 case M_Console_DoCommand
:
138 snipmapcon_docommand(cl
, o
, (struct P_Console_DoCommand
*)msg
);
142 snipmapcon_copy(cl
, o
, msg
);
145 case M_Console_Paste
:
146 snipmapcon_paste(cl
, o
, msg
);
150 case M_Console_HandleGadgets
:
151 D(bug("SnipMapCon::HandleGadgets\n"));
152 snipmapcon_handlegadgets(cl
, o
, (struct P_Console_HandleGadgets
*)msg
);
157 retval
= DoSuperMethodA(cl
, o
, msg
);
168 Class
*makeSnipMapConClass(struct ConsoleBase
*ConsoleDevice
)
172 cl
= MakeClass(NULL
, NULL
, CHARMAPCLASSPTR
,
173 sizeof(struct snipmapcondata
), 0UL);
176 cl
->cl_Dispatcher
.h_Entry
= (APTR
) dispatch_snipmapconclass
;
177 cl
->cl_Dispatcher
.h_SubEntry
= NULL
;
179 cl
->cl_UserData
= (IPTR
) ConsoleDevice
;