revert between 56095 -> 55830 in arch
[AROS.git] / rom / devs / console / snipmapconclass.c
blob047829b2b8688ae718998af59217e8ee4900a5eb
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Code for CONU_SNIPMAP console units.
6 */
8 #include <string.h>
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>
21 #define SDEBUG 0
22 //#define DEBUG 1
23 #define DEBUG 0
24 #include <aros/debug.h>
26 #include "console_gcc.h"
27 #include "consoleif.h"
29 struct snipmapcondata
31 ULONG start_selection_x;
32 ULONG start_selection_y;
35 #ifdef ConsoleDevice
36 #undef ConsoleDevice
37 #endif
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);
45 if (o)
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
64 extract.
66 DoSuperMethodA(cl, o, (Msg) msg);
68 /* FIXME: Handle ConClip here */
70 if conclip running {
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);
92 return;
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);
106 EnterFunc(bug
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)
112 default:
113 DoSuperMethodA(cl, o, (Msg) msg);
114 break;
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))
123 AROS_USERFUNC_INIT
125 IPTR retval = 0UL;
127 switch (msg->MethodID)
129 case OM_NEW:
130 retval = (IPTR) snipmapcon_new(cl, o, (struct opSet *)msg);
131 break;
133 case OM_DISPOSE:
134 snipmapcon_dispose(cl, o, msg);
135 break;
137 case M_Console_DoCommand:
138 snipmapcon_docommand(cl, o, (struct P_Console_DoCommand *)msg);
139 break;
141 case M_Console_Copy:
142 snipmapcon_copy(cl, o, msg);
143 break;
145 case M_Console_Paste:
146 snipmapcon_paste(cl, o, msg);
147 break;
149 #if 0
150 case M_Console_HandleGadgets:
151 D(bug("SnipMapCon::HandleGadgets\n"));
152 snipmapcon_handlegadgets(cl, o, (struct P_Console_HandleGadgets *)msg);
153 break;
154 #endif
156 default:
157 retval = DoSuperMethodA(cl, o, msg);
158 break;
161 return retval;
163 AROS_USERFUNC_EXIT
166 #undef ConsoleDevice
168 Class *makeSnipMapConClass(struct ConsoleBase *ConsoleDevice)
170 Class *cl;
172 cl = MakeClass(NULL, NULL, CHARMAPCLASSPTR,
173 sizeof(struct snipmapcondata), 0UL);
174 if (cl)
176 cl->cl_Dispatcher.h_Entry = (APTR) dispatch_snipmapconclass;
177 cl->cl_Dispatcher.h_SubEntry = NULL;
179 cl->cl_UserData = (IPTR) ConsoleDevice;
181 return (cl);
183 return NULL;