From 03d1c009f0cf9db683b699604f181b267430c6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 30 Jan 2013 22:59:47 +0000 Subject: [PATCH] [CONSRV] - Add a macro which specifies how much space chars a TAB is. - Implement BELL ANSI character handling (basic) and add temporary DPRINTs to see who is called (by the way, Beep() functions seems not to work correctly). svn path=/branches/ros-csrss/; revision=58253 --- win32ss/user/consrv/conio.h | 10 +++++++ win32ss/user/consrv/conoutput.c | 46 +++++++++++++++++++------------- win32ss/user/consrv/guiconsole.c | 14 ++++------ win32ss/user/consrv/tuiconsole.c | 2 +- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/win32ss/user/consrv/conio.h b/win32ss/user/consrv/conio.h index 53496d1bf0a..6d7feee1d39 100644 --- a/win32ss/user/consrv/conio.h +++ b/win32ss/user/consrv/conio.h @@ -9,6 +9,16 @@ #pragma once #define CSR_DEFAULT_CURSOR_SIZE 25 +#define CURSOR_BLINK_TIME 500 +#define DEFAULT_ATTRIB (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED) + +#ifndef WM_APP +#define WM_APP 0x8000 +#endif +#define PM_CREATE_CONSOLE (WM_APP + 1) +#define PM_DESTROY_CONSOLE (WM_APP + 2) +#define PM_CONSOLE_BEEP (WM_APP + 3) + /************************************************************************ * Screen buffer structure represents the win32 screen buffer object. * diff --git a/win32ss/user/consrv/conoutput.c b/win32ss/user/consrv/conoutput.c index 89634cdf582..9949b1cd29d 100644 --- a/win32ss/user/consrv/conoutput.c +++ b/win32ss/user/consrv/conoutput.c @@ -17,6 +17,8 @@ /* GLOBALS ********************************************************************/ +#define TAB_WIDTH 8 + #define ConioInitRect(Rect, top, left, bottom, right) \ do { \ ((Rect)->Top) = top; \ @@ -131,10 +133,22 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, for (i = 0; i < Length; i++) { + /* + * If we are in processed mode, interpret special characters and + * display them correctly. Otherwise, just put them into the buffer. + */ if (Buff->Mode & ENABLE_PROCESSED_OUTPUT) { + /* --- CR --- */ + if (Buffer[i] == '\r') + { + Buff->CurrentX = 0; + UpdateRect.Left = min(UpdateRect.Left, (LONG)Buff->CurrentX); + UpdateRect.Right = max(UpdateRect.Right, (LONG)Buff->CurrentX); + continue; + } /* --- LF --- */ - if (Buffer[i] == '\n') + else if (Buffer[i] == '\n') { Buff->CurrentX = 0; ConioNextLine(Buff, &UpdateRect, &ScrolledLines); @@ -160,30 +174,19 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, Ptr = ConioCoordToPointer(Buff, Buff->CurrentX, Buff->CurrentY); Ptr[0] = ' '; Ptr[1] = Buff->DefaultAttrib; - UpdateRect.Left = min(UpdateRect.Left, (LONG) Buff->CurrentX); - UpdateRect.Right = max(UpdateRect.Right, (LONG) Buff->CurrentX); + UpdateRect.Left = min(UpdateRect.Left, (LONG)Buff->CurrentX); + UpdateRect.Right = max(UpdateRect.Right, (LONG)Buff->CurrentX); } continue; } - /* --- CR --- */ - else if (Buffer[i] == '\r') - { - Buff->CurrentX = 0; - UpdateRect.Left = min(UpdateRect.Left, (LONG) Buff->CurrentX); - UpdateRect.Right = max(UpdateRect.Right, (LONG) Buff->CurrentX); - continue; - } /* --- TAB --- */ else if (Buffer[i] == '\t') { UINT EndX; UpdateRect.Left = min(UpdateRect.Left, (LONG)Buff->CurrentX); - EndX = (Buff->CurrentX + 8) & ~7; - if (EndX > Buff->MaxX) - { - EndX = Buff->MaxX; - } + EndX = (Buff->CurrentX + TAB_WIDTH) & ~(TAB_WIDTH - 1); + EndX = min(EndX, Buff->MaxX); Ptr = ConioCoordToPointer(Buff, Buff->CurrentX, Buff->CurrentY); while (Buff->CurrentX < EndX) { @@ -191,7 +194,7 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, *Ptr++ = Buff->DefaultAttrib; Buff->CurrentX++; } - UpdateRect.Right = max(UpdateRect.Right, (LONG) Buff->CurrentX - 1); + UpdateRect.Right = max(UpdateRect.Right, (LONG)Buff->CurrentX - 1); if (Buff->CurrentX == Buff->MaxX) { if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT) @@ -206,9 +209,16 @@ ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, } continue; } + /* --- BEL ---*/ + else if (Buffer[i] == '\a') + { + DPRINT1("Bell\n"); + SendNotifyMessage(Console->hWindow, PM_CONSOLE_BEEP, 0, 0); + continue; + } } UpdateRect.Left = min(UpdateRect.Left, (LONG)Buff->CurrentX); - UpdateRect.Right = max(UpdateRect.Right, (LONG) Buff->CurrentX); + UpdateRect.Right = max(UpdateRect.Right, (LONG)Buff->CurrentX); Ptr = ConioCoordToPointer(Buff, Buff->CurrentX, Buff->CurrentY); Ptr[0] = Buffer[i]; if (Attrib) diff --git a/win32ss/user/consrv/guiconsole.c b/win32ss/user/consrv/guiconsole.c index 6fe00fb2bfc..ea7d2b40485 100644 --- a/win32ss/user/consrv/guiconsole.c +++ b/win32ss/user/consrv/guiconsole.c @@ -65,15 +65,6 @@ typedef struct _GUI_CONSOLE_DATA POINT OldCursor; } GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA; -#ifndef WM_APP -#define WM_APP 0x8000 -#endif -#define PM_CREATE_CONSOLE (WM_APP + 1) -#define PM_DESTROY_CONSOLE (WM_APP + 2) - -#define CURSOR_BLINK_TIME 500 -#define DEFAULT_ATTRIB (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED) - static BOOL ConsInitialized = FALSE; static HWND NotifyWnd; @@ -2065,6 +2056,11 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) } break; + case PM_CONSOLE_BEEP: + DPRINT1("Beep !!\n"); + Beep(800, 200); + break; + default: Result = DefWindowProcW(hWnd, msg, wParam, lParam); break; diff --git a/win32ss/user/consrv/tuiconsole.c b/win32ss/user/consrv/tuiconsole.c index 0d22e20295b..bd275441249 100644 --- a/win32ss/user/consrv/tuiconsole.c +++ b/win32ss/user/consrv/tuiconsole.c @@ -296,7 +296,7 @@ TuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, LONG CursorStartX, LONG Cur return; } - if (! WriteFile(ConsoleDeviceHandle, Buffer, Length, &BytesWritten, NULL)) + if (!WriteFile(ConsoleDeviceHandle, Buffer, Length, &BytesWritten, NULL)) { DPRINT1("Error writing to BlueScreen\n"); }