ReactOS 0.4.15-dev-7918-g2a2556c
TMouse Class Reference

#include <tmouse.h>

Collaboration diagram for TMouse:

Public Member Functions

void doMouse ()
 
void scrollMouse ()
 
 TMouse (Tnclip &RefClipboard)
 
 ~TMouse ()
 

Private Member Functions

void get_coords (COORD *start_coords, COORD *end_coords, COORD *first_coords, COORD *last_coords)
 
void doMouse_init ()
 
void doMouse_cleanup ()
 
void move_mouse (COORD start_coords, COORD end_coords)
 
void doClip (COORD start_coords, COORD end_coords)
 

Private Attributes

int normal
 
int inverse
 
HANDLE hConsole
 
HANDLE hStdout
 
CHAR_INFOchiBuffer
 
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
 
TnclipClipboard
 

Detailed Description

Definition at line 6 of file tmouse.h.

Constructor & Destructor Documentation

◆ TMouse()

TMouse::TMouse ( Tnclip RefClipboard)

Definition at line 33 of file tmouse.cpp.

33 : Clipboard(RefClipboard) {
36}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
HANDLE hConsole
Definition: tmouse.h:9
HANDLE hStdout
Definition: tmouse.h:9
Tnclip & Clipboard
Definition: tmouse.h:12
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define STD_INPUT_HANDLE
Definition: winbase.h:267

◆ ~TMouse()

TMouse::~TMouse ( )

Definition at line 38 of file tmouse.cpp.

38 {
39}

Member Function Documentation

◆ doClip()

void TMouse::doClip ( COORD  start_coords,
COORD  end_coords 
)
private

Definition at line 80 of file tmouse.cpp.

80 {
81 // COORD screen_start = {0, 0};
82 COORD first_coords, last_coords;
84
85 get_coords(&start_coords, &end_coords, &first_coords, &last_coords);
86
87 // Allocate the minimal size buffer
88 int data_size = 3 + ConsoleInfo.dwSize.X *
89 (last_coords.Y - first_coords.Y) + (last_coords.X - first_coords.X);
91 data_size);
92 LPVOID mem_ptr = GlobalLock(clipboard_data);
93
94 // Reset data_size so we can count the actual data size
95 data_size = 0;
96
97 // Read the console, put carriage returns at the end of each line if
98 // reading more than one line (Paul Brannan 9/17/98)
99 for(int j = first_coords.Y; j <= last_coords.Y; j++) {
100
101 // Read line at (0,j)
103 coords.X = 0;
104 coords.Y = j;
106
107 if(j == first_coords.Y) {
108 coords.X = first_coords.X;
109 length = ConsoleInfo.dwSize.X - first_coords.X;
110 } else {
111 // Add a carriage return to the end of the previous line
112 *((char *)mem_ptr + data_size++) = '\r';
113 *((char *)mem_ptr + data_size++) = '\n';
114 }
115
116 if(j == last_coords.Y) {
117 length -= (ConsoleInfo.dwSize.X - last_coords.X);
118 }
119
120 // Read the next line
121 ReadConsoleOutputCharacter(hStdout, (LPTSTR)((char *)mem_ptr +
122 data_size), length, coords, &Result);
123 data_size += Result;
124
125 // Strip the spaces at the end of the line
126 if((j != last_coords.Y) && (first_coords.Y != last_coords.Y))
127 while(*((char *)mem_ptr + data_size - 1) == ' ') data_size--;
128 }
129 if(first_coords.Y != last_coords.Y) {
130 // Add a carriage return to the end of the last line
131 *((char *)mem_ptr + data_size++) = '\r';
132 *((char *)mem_ptr + data_size++) = '\n';
133 }
134
135 *((char *)mem_ptr + data_size) = 0;
136 GlobalUnlock(clipboard_data);
137
138 Clipboard.Copy(clipboard_data);
139}
void get_coords(COORD *start_coords, COORD *end_coords, COORD *first_coords, COORD *last_coords)
Definition: tmouse.cpp:41
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: tmouse.h:11
void Copy(HGLOBAL clipboard_data)
Definition: tnclip.cpp:40
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint coords
Definition: glext.h:7368
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
SHORT X
Definition: blue.h:26
#define GMEM_MOVEABLE
Definition: winbase.h:294
#define GMEM_DDESHARE
Definition: winbase.h:298
#define ReadConsoleOutputCharacter
Definition: wincon.h:781
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by doMouse().

◆ doMouse()

void TMouse::doMouse ( )

Definition at line 141 of file tmouse.cpp.

141 {
142 INPUT_RECORD InputRecord;
144 InputRecord.EventType = KEY_EVENT; // just in case
145 while(InputRecord.EventType != MOUSE_EVENT) {
146 if (!ReadConsoleInput(hConsole, &InputRecord, 1, &Result))
147 return; // uh oh! we don't know the starting coordinates!
148 }
149 if(InputRecord.Event.MouseEvent.dwButtonState == 0) return;
150 if(!(InputRecord.Event.MouseEvent.dwButtonState &
153 return;
154 }
155
156 COORD screen_start = {0, 0};
157 COORD start_coords = InputRecord.Event.MouseEvent.dwMousePosition;
158 COORD end_coords = start_coords;
159 BOOL done = FALSE;
160
161 // init vars
162 doMouse_init();
163 int normal_bg = ini.get_normal_bg();
164 int normal_fg = ini.get_normal_fg();
165 if(normal_bg == -1) normal_bg = 0; // FIX ME!! This is just a hack
166 if(normal_fg == -1) normal_fg = 7;
167 normal = (normal_bg << 4) | normal_fg;
168 inverse = (normal_fg << 4) | normal_bg;
169
170 // make screen all one attribute
172 ConsoleInfo.dwSize.Y, screen_start, &Result);
173
174 while(!done) {
175
176 switch (InputRecord.EventType) {
177 case MOUSE_EVENT:
178 switch(InputRecord.Event.MouseEvent.dwEventFlags) {
179 case 0: // only copy if the mouse button has been released
180 if(!InputRecord.Event.MouseEvent.dwButtonState) {
181 doClip(start_coords, end_coords);
182 done = TRUE;
183 }
184 break;
185
186 case MOUSE_MOVED:
187 end_coords = InputRecord.Event.MouseEvent.dwMousePosition;
188 move_mouse(start_coords, end_coords);
189 break;
190 }
191 break;
192 // If we are changing focus, we don't want to highlight anything
193 // (Paul Brannan 9/2/98)
194 case FOCUS_EVENT:
195 return;
196 }
197
199 if (!ReadConsoleInput(hConsole, &InputRecord, 1, &Result))
200 done = TRUE;
201
202 }
203
205}
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:525
int get_normal_fg() const
Definition: tnconfig.h:72
int get_normal_bg() const
Definition: tnconfig.h:71
int normal
Definition: tmouse.h:8
int inverse
Definition: tmouse.h:8
void move_mouse(COORD start_coords, COORD end_coords)
Definition: tmouse.cpp:66
void doClip(COORD start_coords, COORD end_coords)
Definition: tmouse.cpp:80
void doMouse_cleanup()
Definition: tmouse.cpp:61
void doMouse_init()
Definition: tmouse.cpp:55
void Paste()
Definition: tnclip.cpp:48
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
MOUSE_EVENT_RECORD MouseEvent
Definition: wincon.h:276
union _INPUT_RECORD::@3292 Event
WORD EventType
Definition: wincon.h:273
DWORD dwEventFlags
Definition: wincon.h:257
DWORD dwButtonState
Definition: wincon.h:255
COORD dwMousePosition
Definition: wincon.h:254
SHORT Y
Definition: blue.h:27
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
TConfig ini
Definition: tnconfig.cpp:45
#define ReadConsoleInput
Definition: wincon.h:778
#define MOUSE_EVENT
Definition: wincon.h:129
#define KEY_EVENT
Definition: wincon.h:128
#define MOUSE_MOVED
Definition: wincon.h:168
#define FROM_LEFT_1ST_BUTTON_PRESSED
Definition: wincon.h:159
#define FOCUS_EVENT
Definition: wincon.h:132

Referenced by scrollMouse().

◆ doMouse_cleanup()

void TMouse::doMouse_cleanup ( )
private

Definition at line 61 of file tmouse.cpp.

61 {
63 delete[] chiBuffer;
64}
CHAR_INFO * chiBuffer
Definition: tmouse.h:10
void restoreScreen(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:964

Referenced by doMouse().

◆ doMouse_init()

void TMouse::doMouse_init ( )
private

Definition at line 55 of file tmouse.cpp.

55 {
59}
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
void saveScreen(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:934
CHAR_INFO * newBuffer()
Definition: tconsole.cpp:995

Referenced by doMouse().

◆ get_coords()

void TMouse::get_coords ( COORD start_coords,
COORD end_coords,
COORD first_coords,
COORD last_coords 
)
private

Definition at line 41 of file tmouse.cpp.

42 {
43 if(end_coords->Y < start_coords->Y ||
44 (end_coords->Y == start_coords->Y && end_coords->X < start_coords->X))
45 {
46 *first_coords = *end_coords;
47 *last_coords = *start_coords;
48 } else {
49 *first_coords = *start_coords;
50 *last_coords = *end_coords;
51 }
52 last_coords->X++;
53}

Referenced by doClip(), and move_mouse().

◆ move_mouse()

void TMouse::move_mouse ( COORD  start_coords,
COORD  end_coords 
)
private

Definition at line 66 of file tmouse.cpp.

66 {
67 COORD screen_start = {0, 0};
68 COORD first_coords, last_coords;
70
72 ConsoleInfo.dwSize.X * ConsoleInfo.dwSize.Y, screen_start, &Result);
73
74 get_coords(&start_coords, &end_coords, &first_coords, &last_coords);
76 (last_coords.Y - first_coords.Y) + (last_coords.X - first_coords.X),
77 first_coords, &Result);
78}

Referenced by doMouse().

◆ scrollMouse()

void TMouse::scrollMouse ( )

Definition at line 207 of file tmouse.cpp.

207 {
208 doMouse();
209}
void doMouse()
Definition: tmouse.cpp:141

Referenced by TScroller::ScrollBack().

Member Data Documentation

◆ chiBuffer

CHAR_INFO* TMouse::chiBuffer
private

Definition at line 10 of file tmouse.h.

Referenced by doMouse_cleanup(), and doMouse_init().

◆ Clipboard

Tnclip& TMouse::Clipboard
private

Definition at line 12 of file tmouse.h.

Referenced by doClip(), and doMouse().

◆ ConsoleInfo

CONSOLE_SCREEN_BUFFER_INFO TMouse::ConsoleInfo
private

Definition at line 11 of file tmouse.h.

Referenced by doClip(), doMouse(), doMouse_init(), and move_mouse().

◆ hConsole

HANDLE TMouse::hConsole
private

Definition at line 9 of file tmouse.h.

Referenced by doMouse(), and TMouse().

◆ hStdout

HANDLE TMouse::hStdout
private

Definition at line 9 of file tmouse.h.

Referenced by doClip(), doMouse(), doMouse_init(), move_mouse(), and TMouse().

◆ inverse

int TMouse::inverse
private

Definition at line 8 of file tmouse.h.

Referenced by doMouse(), and move_mouse().

◆ normal

int TMouse::normal
private

Definition at line 8 of file tmouse.h.

Referenced by doMouse(), and move_mouse().


The documentation for this class was generated from the following files: