No longer directly accessing debuggee memory.
[wine] / graphics / ttydrv / text.c
1 /*
2  * TTY DC text
3  *
4  * Copyright 1999 Patrik Stridvall
5  */
6
7 #include "config.h"
8
9 #include "windef.h"
10 #include "wingdi.h"
11 #include "dc.h"
12 #include "debugtools.h"
13 #include "gdi.h"
14 #include "ttydrv.h"
15
16 DEFAULT_DEBUG_CHANNEL(ttydrv);
17
18 /***********************************************************************
19  *              TTYDRV_DC_ExtTextOut
20  */
21 BOOL TTYDRV_DC_ExtTextOut(DC *dc, INT x, INT y, UINT flags,
22                           const RECT *lpRect, LPCWSTR str, UINT count,
23                           const INT *lpDx)
24 {
25 #ifdef HAVE_LIBCURSES
26   TTYDRV_PDEVICE *physDev = (TTYDRV_PDEVICE *) dc->physDev;
27   INT row, col;
28   LPSTR ascii;
29
30   TRACE("(%p, %d, %d, 0x%08x, %p, %s, %d, %p)\n",
31         dc, x, y, flags, lpRect, debugstr_wn(str, count), count, lpDx);
32
33   if(!physDev->window)
34     return FALSE;
35
36   /* FIXME: Is this really correct? */
37   if(dc->w.textAlign & TA_UPDATECP) {
38     x = dc->w.CursPosX;
39     y = dc->w.CursPosY;
40   }
41
42   x = XLPTODP(dc, x);
43   y = YLPTODP(dc, y);
44   
45   row = (dc->w.DCOrgY + y) / physDev->cellHeight;
46   col = (dc->w.DCOrgX + x) / physDev->cellWidth;
47   ascii = HeapAlloc( GetProcessHeap(), 0, count+1 );
48   lstrcpynWtoA(ascii, str, count+1);
49   mvwaddnstr(physDev->window, row, col, ascii, count);
50   HeapFree( GetProcessHeap(), 0, ascii );
51   wrefresh(physDev->window);
52
53   if(dc->w.textAlign & TA_UPDATECP) {
54     dc->w.CursPosX += count * physDev->cellWidth;
55     dc->w.CursPosY += physDev->cellHeight;
56   }
57
58   return TRUE;
59 #else /* defined(HAVE_LIBCURSES) */
60   FIXME("(%p, %d, %d, 0x%08x, %p, %s, %d, %p): stub\n",
61         dc, x, y, flags, lpRect, debugstr_wn(str,count), count, lpDx);
62
63   return TRUE;
64 #endif /* defined(HAVE_LIBCURSES) */
65 }