** WIP ** Some fixes, usability fixes, and tweaks

And many more will come next...
This commit is contained in:
Hermès Bélusca-Maïto
2025-11-02 22:54:59 +01:00
parent 3d51117282
commit 0ce7de701a
17 changed files with 427 additions and 87 deletions

View File

@@ -1,4 +1,6 @@
PROJECT(edit)
list(APPEND DFLAT_SOURCE
fdeditw32/applicat.c
## fdeditw32/barchart.c
@@ -9,7 +11,7 @@ list(APPEND DFLAT_SOURCE
fdeditw32/clipbord.c
fdeditw32/combobox.c
fdeditw32/config.c
fdeditw32/console.c
## fdeditw32/console.c ## Win32 implementation in console_w32.c
fdeditw32/decomp.c
fdeditw32/dfalloc.c
fdeditw32/dialbox.c
@@ -25,7 +27,7 @@ list(APPEND DFLAT_SOURCE
fdeditw32/menu.c
fdeditw32/menubar.c
fdeditw32/message.c
fdeditw32/mouse.c
## fdeditw32/mouse.c ## Win32 implementation in console_w32.c
fdeditw32/msgbox.c
fdeditw32/normal.c
fdeditw32/pictbox.c
@@ -39,21 +41,40 @@ list(APPEND DFLAT_SOURCE
fdeditw32/sysmenu.c
fdeditw32/text.c
fdeditw32/textbox.c
fdeditw32/video.c
## fdeditw32/video.c ## Win32 implementation in video_w32.c
fdeditw32/watch.c
fdeditw32/window.c
)
add_library(dflat20_static ${DFLAT_SOURCE})
## FILES += timer_w32 country_w32 dir_w32 video_w32 console_w32 clipbord_w32
list(APPEND DFLAT_SOURCE_WIN32
fdeditw32/clipbord_w32.c ## Win32 implementation for some clipbord.c helpers
fdeditw32/console_w32.c
fdeditw32/country_w32.c
fdeditw32/dir_w32.c ## Win32 implementation of directory/drive functions
fdeditw32/timer_w32.c ## Win32 implementation for timer functions in message.c
fdeditw32/video_w32.c
)
add_library(dflat20_static ${DFLAT_SOURCE} ${DFLAT_SOURCE_WIN32})
target_compile_definitions(dflat20_static PRIVATE
_CRT_DECLARE_NONSTDC_NAMES=1 # This must be set to 1
_CRT_NONSTDC_NO_DEPRECATE
INCLUDE_PICTUREBOX
INCLUDE_MULTI_WINDOWS
# INCLUDE_WINDOWOPTIONS
INCLUDE_MAXIMIZE
INCLUDE_MINIMIZE
INCLUDE_RESTORE
INCLUDE_EXTENDEDSELECTIONS
INCLUDE_SHELLDOS
_FDEDIT_PRIVATE_CLIPBOARD
)
add_executable(huffc fdeditw32/huffc.c fdeditw32/htree.c)
set_module_type(huffc win32cui) ## UNICODE
add_importlibs(huffc user32 msvcrt kernel32)
add_importlibs(huffc msvcrt kernel32)
add_executable(fixhelp fdeditw32/decomp.c fdeditw32/fixhelp.c)
set_module_type(fixhelp win32cui) ## UNICODE
add_importlibs(fixhelp user32 msvcrt kernel32)
add_importlibs(fixhelp msvcrt kernel32)
# add_custom_target(edit_help DEPENDS ${rosapps_converted_item})
@@ -72,17 +93,21 @@ list(APPEND EDIT_SOURCE
)
add_executable(edit ${EDIT_SOURCE} edit.rc)
target_compile_definitions(edit PRIVATE
##_CRT_DECLARE_NONSTDC_NAMES=1 # This must be set to 1
##_CRT_NONSTDC_NO_DEPRECATE
INCLUDE_PICTUREBOX
INCLUDE_MULTI_WINDOWS
INCLUDE_WINDOWOPTIONS
# INCLUDE_WINDOWOPTIONS
INCLUDE_MAXIMIZE
INCLUDE_MINIMIZE
INCLUDE_RESTORE
INCLUDE_EXTENDEDSELECTIONS
INCLUDE_SHELLDOS
_FDEDIT_PRIVATE_CLIPBOARD
)
set_module_type(edit win32cui) ## UNICODE
target_link_libraries(edit dflat20_static oldnames)
add_importlibs(edit user32 msvcrt kernel32)
set_target_properties(edit PROPERTIES OUTPUT_NAME "edit" SUFFIX ".com")
#set_target_properties(edit PROPERTIES OUTPUT_NAME "edit" SUFFIX ".com")
add_cd_file(TARGET edit DESTINATION reactos/system32 FOR all)

View File

@@ -468,9 +468,9 @@ static void ShellDOS(WINDOW wnd)
SetScreenHeight(ScreenHeight);
SendMessage(NULL, HIDE_MOUSE, 0, 0);
printf("Type EXIT to return to %s.\n\n", DFlatApplication);
fflush(stdout);
spawnl(P_WAIT, getenv("COMSPEC"), NULL);
//printf("Type EXIT to return to %s.\n\n", DFlatApplication);
//fflush(stdout);
//spawnl(P_WAIT, getenv("COMSPEC"), NULL);
if (SCREENHEIGHT != cfg.ScreenLines)
SetScreenHeight(cfg.ScreenLines);
@@ -774,6 +774,7 @@ static void SelectLines(WINDOW wnd)
if (SCREENHEIGHT != cfg.ScreenLines)
{
SetScreenHeight(cfg.ScreenLines);
/* ---- re-maximize ---- */
if (wnd->condition==ISMAXIMIZED)
{
SendMessage(wnd, SIZE, (PARAM) GetRight(wnd), SCREENHEIGHT-1);

View File

@@ -5,6 +5,10 @@
void PaintMsg(WINDOW wnd, CTLWINDOW *ct, RECT *rc)
{
if (isVisible(wnd)) {
#ifdef __REACTOS__
// if (ct->setting != ON)
// PaintShadow(wnd);
#endif
if (TestAttribute(wnd, SHADOW) && cfg.mono == 0) {
/* -------- draw the button's shadow ------- */
int x;
@@ -37,6 +41,7 @@ void PaintMsg(WINDOW wnd, CTLWINDOW *ct, RECT *rc)
void LeftButtonMsg(WINDOW wnd, MESSAGE msg, CTLWINDOW *ct)
{
#if 1 // ndef __REACTOS__
if (cfg.mono == 0) {
/* --------- draw a pushed button -------- */
int x;
@@ -48,15 +53,21 @@ void LeftButtonMsg(WINDOW wnd, MESSAGE msg, CTLWINDOW *ct)
wputch(wnd, 223, x+1, 1);
}
}
#endif
#ifdef __REACTOS__
SendMessage(wnd, PAINT, 0, 0);
#endif
if (msg == LEFT_BUTTON)
SendMessage(NULL, WAITMOUSE, 0, 0);
else
SendMessage(NULL, WAITKEYBOARD, 0, 0);
#ifndef __REACTOS__
SendMessage(wnd, PAINT, 0, 0);
if (ct->setting == ON)
PostMessage(GetParent(wnd), COMMAND, ct->command, 0);
else
beep();
#endif
}
int ButtonProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
@@ -75,6 +86,14 @@ int ButtonProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
if (p1 != '\r')
break;
/* ---- fall through ---- */
#ifdef __REACTOS__
case BUTTON_RELEASED:
if (ct->setting == ON)
PostMessage(GetParent(wnd), COMMAND, ct->command, 0);
else
beep();
/*break;*/return TRUE;
#endif
case LEFT_BUTTON:
LeftButtonMsg(wnd, msg, ct);
return TRUE;

View File

@@ -27,7 +27,11 @@ int CheckBoxProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
case KEYBOARD:
if ((int)p1 != ' ')
break;
#ifdef __REACTOS__
case BUTTON_RELEASED:
#else
case LEFT_BUTTON:
#endif
ct->setting ^= ON;
SendMessage(wnd, PAINT, 0, 0);
return TRUE;

View File

@@ -2,6 +2,8 @@
#include "dflat.h"
#define TV_COLORS
/* ----- default colors for color video system ----- */
unsigned char color[CLASSCOUNT] [4] [2] = {
/* ------------ NORMAL ------------ */
@@ -30,21 +32,36 @@ unsigned char color[CLASSCOUNT] [4] [2] = {
/* ----------- EDITBOX ------------ */
{{LIGHTGRAY, BLUE}, /* STD_COLOR */
#ifdef TV_COLORS
{LIGHTGRAY, GREEN}, /* SELECT_COLOR */
#else
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
#endif
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
/* ---------- MENUBAR ------------- */
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
#ifdef TV_COLORS
{BLACK, GREEN}, /* SELECT_COLOR */
#else
{BLACK, CYAN}, /* SELECT_COLOR */
#endif
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
{DARKGRAY, RED}}, /* HILITE_COLOR
Inactive, Shortcut (both FG) */
/* ---------- POPDOWNMENU --------- */
{{BLACK, CYAN}, /* STD_COLOR */
{
#ifdef TV_COLORS
{BLACK, LIGHTGRAY}, /* STD_COLOR */
{BLACK, GREEN}, /* SELECT_COLOR */
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
#else
{BLACK, CYAN}, /* STD_COLOR */
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
{BLACK, CYAN}, /* FRAME_COLOR */
#endif
{DARKGRAY, RED}}, /* HILITE_COLOR
Inactive ,Shortcut (both FG) */
@@ -69,9 +86,16 @@ unsigned char color[CLASSCOUNT] [4] [2] = {
{LIGHTGRAY, BLUE}}, /* HILITE_COLOR */
/* ------------ BUTTON ------------ */
{{BLACK, CYAN}, /* STD_COLOR */
{
#ifdef TV_COLORS
{BLACK, CYAN}, /* STD_COLOR */
{WHITE, CYAN}, /* SELECT_COLOR */
{BLACK, CYAN}, /* FRAME_COLOR */
#else
{BLACK, CYAN}, /* STD_COLOR */
{WHITE, CYAN}, /* SELECT_COLOR */
{BLACK, CYAN}, /* FRAME_COLOR */
#endif
{DARKGRAY, RED}}, /* HILITE_COLOR
Inactive ,Shortcut (both FG) */
/* ------------ COMBOBOX ----------- */
@@ -123,22 +147,37 @@ unsigned char color[CLASSCOUNT] [4] [2] = {
{WHITE, LIGHTGRAY}},/* HILITE_COLOR */
/* ---------- STATUSBAR ------------- */
#ifdef TV_COLORS
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
#else
{{BLACK, CYAN}, /* STD_COLOR */
{BLACK, CYAN}, /* SELECT_COLOR */
{BLACK, CYAN}, /* FRAME_COLOR */
{BLACK, CYAN}}, /* HILITE_COLOR */
#endif
/* ----------- EDITOR ------------ */
{{LIGHTGRAY, BLUE}, /* STD_COLOR */
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
{BLUE, LIGHTRED}, /* SELECT_COLOR */
{BLUE, LIGHTRED}, /* FRAME_COLOR */
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
/* ---------- TITLEBAR ------------ */
{{BLACK, CYAN}, /* STD_COLOR */
{
#ifdef TV_COLORS
{BLACK, RED}, /* STD_COLOR */
{BLACK, GREEN}, /* SELECT_COLOR */
{MAGENTA, BLACK}, /* FRAME_COLOR */
{WHITE, BLACK}}, /* HILITE_COLOR */
#else
{BLACK, CYAN}, /* STD_COLOR */
{BLACK, CYAN}, /* SELECT_COLOR */
{CYAN, BLACK}, /* FRAME_COLOR */
{WHITE, CYAN}}, /* HILITE_COLOR */
#endif
/* ------------ DUMMY ------------- */
{{GREEN, LIGHTGRAY}, /* STD_COLOR */
@@ -445,13 +484,21 @@ CONFIG cfg = {
4, /* Editor tab stops */
FALSE, /* Editor word wrap */
0, /* Read Only? */
#ifdef __REACTOS__
TRUE, /* Load blank file on startup */
#else
FALSE, /* Load blank file on startup */
#endif
#ifdef INCLUDE_WINDOWOPTIONS
TRUE, /* Application Border */
TRUE, /* Application Title */
TRUE, /* Status Bar */
#endif
#ifdef __REACTOS__ // && TV_COLORS
TRUE, /* Textured application window */
#else
FALSE, /* Textured application window */
#endif
25, /* Number of screen lines */
"Lpt1", /* Printer Port */
66, /* Lines per printer page */
@@ -481,7 +528,11 @@ void BuildFileName(char *path, const char *fn, const char *ext)
FILE *OpenConfig(char *mode)
{
#if defined(_WIN32) && defined(__REACTOS__)
char path[MAX_PATH];
#else
char path[64];
#endif
BuildFileName(path, DFlatApplication, ".cfg");
return fopen(path, mode);
@@ -507,7 +558,11 @@ BOOL LoadConfig(void)
}
else
{
#if defined(_WIN32) && defined(__REACTOS__)
char path[MAX_PATH];
#else
char path[64];
#endif
BuildFileName(path, DFlatApplication, ".cfg");
fclose(fp);

View File

@@ -2,6 +2,16 @@
#include <windows.h>
#ifdef __REACTOS__
/* See sdk/include/reactos/wincon_undoc.h */
WINBASEAPI
INT
WINAPI
ShowConsoleCursor(
_In_ HANDLE hConsoleOutput,
_In_ BOOL bShow);
#endif
#include "keys.h"
#define MAXSAVES 50
@@ -49,7 +59,7 @@ static const WORD col_fore[] = {
FOREGROUND_INTENSITY,
FOREGROUND_RED | /* LIGHTRED */
FOREGROUND_INTENSITY,
FOREGROUND_BLUE | /* MAGENTA */
FOREGROUND_BLUE | /* LIGHTMAGENTA */
FOREGROUND_RED |
FOREGROUND_INTENSITY,
FOREGROUND_RED | /* YELLOW */
@@ -91,7 +101,7 @@ static const WORD col_back[] = {
BACKGROUND_INTENSITY,
BACKGROUND_RED | /* LIGHTRED */
BACKGROUND_INTENSITY,
BACKGROUND_BLUE | /* MAGENTA */
BACKGROUND_BLUE | /* LIGHTMAGENTA */
BACKGROUND_RED |
BACKGROUND_INTENSITY,
BACKGROUND_RED | /* YELLOW */
@@ -112,9 +122,7 @@ static HANDLE hConsoleOut;
static HANDLE hNewScreenBuffer;
static CONSOLE_SCREEN_BUFFER_INFO csbi;
static SMALL_RECT updateRect;
static COORD updateCoord;
static COORD updateCoordSrc;
static CHAR_INFO *chiBuffer;
static unsigned char *coiBuffer;
static COORD lastCurPos;
@@ -206,7 +214,7 @@ static const key_tbl_t key_tbl3[] = {
static keyb_t keyb = { 0, 0, { 0 } };
int w32_getkey()
int w32_getkey(void)
{
DWORD dwInputs;
INPUT_RECORD inRec;
@@ -353,34 +361,121 @@ void videomode(void)
*/
}
void init_videomode(void)
#ifdef __REACTOS__
/*
* See, or adjust if needed, base/applications/cmdutils/mode/mode.c and
* subsystems/mvdm/ntvdm/console/video.c!ResizeTextConsole() implementations
* for more information.
*/
static BOOL
ResizeTextConsole(
_In_ HANDLE hConOut,
_Inout_ PCONSOLE_SCREEN_BUFFER_INFO pcsbi,
_In_ COORD Resolution)
{
CONSOLE_CURSOR_INFO curInfo;
DWORD dwMode;
BOOL Success;
SHORT Width, Height;
SMALL_RECT ConRect;
/*
* Use this trick to effectively resize the console buffer and window,
* because:
* - SetConsoleScreenBufferSize fails if the new console screen buffer size
* is smaller than the current console window size, and:
* - SetConsoleWindowInfo fails if the new console window size is larger
* than the current console screen buffer size.
*/
/* Resize the screen buffer only if needed */
if (Resolution.X != pcsbi->dwSize.X || Resolution.Y != pcsbi->dwSize.Y)
{
Width = pcsbi->srWindow.Right - pcsbi->srWindow.Left + 1;
Height = pcsbi->srWindow.Bottom - pcsbi->srWindow.Top + 1;
/*
* If the current console window is too large for
* the new screen buffer, resize it first.
*/
if (Width > Resolution.X || Height > Resolution.Y)
{
/*
* NOTE: This is not a problem if we move the window back to (0,0)
* because when we resize the screen buffer, the window will move back
* to where the cursor is. Or, if the screen buffer is not resized,
* when we readjust again the window, we will move back to a correct
* position. This is what we wanted after all...
*/
ConRect.Left = ConRect.Top = 0;
ConRect.Right = ConRect.Left + min(Width , Resolution.X) - 1;
ConRect.Bottom = ConRect.Top + min(Height, Resolution.Y) - 1;
Success = SetConsoleWindowInfo(hConOut, TRUE, &ConRect);
if (!Success) return FALSE;
}
/*
* Now resize the screen buffer.
*
* SetConsoleScreenBufferSize automatically takes into account the current
* cursor position when it computes starting which row it should copy text
* when resizing the screen buffer, and scrolls the console window such that
* the cursor is placed in it again. We therefore do not need to care about
* the cursor position and do the maths ourselves.
*/
Success = SetConsoleScreenBufferSize(hConOut, Resolution);
if (!Success) return FALSE;
/*
* Setting a new screen buffer size can change other information,
* so update the console screen buffer information.
*/
GetConsoleScreenBufferInfo(hConOut, pcsbi);
}
/* Always resize the console window within the permitted maximum size */
Width = min(Resolution.X, pcsbi->dwMaximumWindowSize.X);
Height = min(Resolution.Y, pcsbi->dwMaximumWindowSize.Y);
ConRect.Left = 0;
ConRect.Right = ConRect.Left + Width - 1;
ConRect.Bottom = max(pcsbi->dwCursorPosition.Y, Height - 1);
ConRect.Top = ConRect.Bottom - Height + 1;
SetConsoleWindowInfo(hConOut, TRUE, &ConRect);
/* Update the console screen buffer information */
GetConsoleScreenBufferInfo(hConOut, pcsbi);
return TRUE;
}
static void
SetConsoleHeight(SHORT height)
{
void* bufptr;
COORD Resolution;
int x,y;
SMALL_RECT updateRect;
COORD updateCoordSrc;
if (initialized_vmode)
if (height <= 0)
return;
initialized_vmode = TRUE;
hConsoleIn = GetStdHandle(STD_INPUT_HANDLE);
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
hNewScreenBuffer = CreateConsoleScreenBuffer(
GENERIC_READ | /* read/write access */
GENERIC_WRITE,
0, /* not shared */
NULL, /* default security attributes */
CONSOLE_TEXTMODE_BUFFER, /* must be TEXTMODE */
NULL);
Resolution.X = csbi.dwSize.X; // 80;
Resolution.Y = height;
if (!ResizeTextConsole(hNewScreenBuffer, &csbi, Resolution))
return;
GetConsoleScreenBufferInfo(hConsoleOut, &csbi);
origCurPos = csbi.dwCursorPosition;
SetConsoleActiveScreenBuffer(hNewScreenBuffer);
updateCoord.X = csbi.dwSize.X;
/* updateCoord.Y = csbi.dwSize.Y; */
updateCoord.Y = 25;
chiBuffer = (CHAR_INFO *)malloc(updateCoord.X*updateCoord.Y*sizeof(CHAR_INFO));
coiBuffer = (unsigned char *)malloc(updateCoord.X*updateCoord.Y);
updateCoord.Y = csbi.dwSize.Y;
/* NOTA: If the buffers are originally NULL, realloc == malloc */
bufptr = realloc(chiBuffer, updateCoord.X*updateCoord.Y*sizeof(CHAR_INFO));
if (bufptr)
chiBuffer = (CHAR_INFO *)bufptr;
bufptr = realloc(coiBuffer, updateCoord.X*updateCoord.Y);
if (bufptr)
coiBuffer = (unsigned char *)bufptr;
updateCoordSrc.X = 0;
updateCoordSrc.Y = 0;
updateRect.Top = 0;
@@ -390,17 +485,47 @@ void init_videomode(void)
for (y=0; y<updateCoord.Y; y++) {
for (x=0; x<updateCoord.X; x++) {
chiBuffer[x+y*updateCoord.X].Char.AsciiChar = ' ';
chiBuffer[x+y*updateCoord.X].Attributes = 0;
int n = x+y*updateCoord.X;
chiBuffer[n].Char.AsciiChar = ' ';
chiBuffer[n].Attributes = 0;
/**/coiBuffer[n] = 1;/**/
}
}
WriteConsoleOutput(
WriteConsoleOutput(
hNewScreenBuffer,
chiBuffer,
updateCoord,
updateCoordSrc,
&updateRect);
}
#endif
void init_videomode(void)
{
CONSOLE_CURSOR_INFO curInfo;
DWORD dwMode;
if (initialized_vmode)
return;
initialized_vmode = TRUE;
hConsoleIn = GetStdHandle(STD_INPUT_HANDLE);
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
hNewScreenBuffer = CreateConsoleScreenBuffer(
GENERIC_READ | /* read/write access */
GENERIC_WRITE,
0, /* not shared */
NULL, /* default security attributes */
CONSOLE_TEXTMODE_BUFFER, /* must be TEXTMODE */
NULL);
GetConsoleScreenBufferInfo(hConsoleOut, &csbi);
origCurPos = csbi.dwCursorPosition;
SetConsoleActiveScreenBuffer(hNewScreenBuffer);
/* Initially start in 80x25 mode */
SetConsoleHeight(25);
GetConsoleMode(hConsoleIn, &dwMode);
/*
@@ -527,28 +652,37 @@ void set_cursor_type(unsigned t)
/* ---- test for EGA -------- */
BOOL isEGA(void)
{
return 0;
return FALSE;
}
/* ---- test for VGA -------- */
BOOL isVGA(void)
{
return 1;
return TRUE;
}
/* ---------- set 25 line mode ------- */
void Set25(void)
{
#ifdef __REACTOS__
SetConsoleHeight(25);
#endif
}
/* ---------- set 43 line mode ------- */
void Set43(void)
{
#ifdef __REACTOS__
SetConsoleHeight(43);
#endif
}
/* ---------- set 50 line mode ------- */
void Set50(void)
{
#ifdef __REACTOS__
SetConsoleHeight(50);
#endif
}
/* ------ convert an Alt+ key to its letter equivalent ----- */
@@ -568,26 +702,26 @@ int AltConvert(int c)
void w32_put_video(int x, int y, int ch_att)
{
SMALL_RECT srctRect;
COORD coordBufCoord;
COORD updateCoordSrc;
int n = x+y*updateCoord.X;
chiBuffer[x+y*updateCoord.X].Char.AsciiChar = ch_att & 0xFF;
chiBuffer[n].Char.AsciiChar = ch_att & 0xFF;
ch_att >>= 8;
coiBuffer[x+y*updateCoord.X] = ch_att;
chiBuffer[x+y*updateCoord.X].Attributes = col_fore[ch_att & 0xF] |
col_back[ch_att >> 4];
coiBuffer[n] = ch_att;
chiBuffer[n].Attributes = col_fore[ch_att & 0xF] | col_back[ch_att >> 4];
srctRect.Top = y;
srctRect.Left = x;
srctRect.Bottom = y;
srctRect.Right = x;
coordBufCoord.X = x;
coordBufCoord.Y = y;
WriteConsoleOutput(
updateCoordSrc.X = x;
updateCoordSrc.Y = y;
WriteConsoleOutput(
hNewScreenBuffer,
chiBuffer,
updateCoord,
coordBufCoord,
updateCoordSrc,
&srctRect);
}
@@ -601,7 +735,7 @@ void w32_scroll_up(int x1,int y1,int x2,int y2,int attr)
{
int x,y,addr1,addr2,ch_att;
SMALL_RECT srctRect;
COORD coordBufCoord;
COORD updateCoordSrc;
ch_att = col_fore[attr & 0xF] | col_back[attr >> 4];
addr1 = y1*updateCoord.X;
@@ -623,15 +757,15 @@ void w32_scroll_up(int x1,int y1,int x2,int y2,int attr)
srctRect.Left = x1;
srctRect.Bottom = y2;
srctRect.Right = x2;
coordBufCoord.X = x1;
coordBufCoord.Y = y1;
WriteConsoleOutput(
updateCoordSrc.X = x1;
updateCoordSrc.Y = y1;
WriteConsoleOutput(
hNewScreenBuffer,
chiBuffer,
updateCoord,
coordBufCoord,
updateCoordSrc,
&srctRect);
}
@@ -639,7 +773,7 @@ void w32_scroll_dw(int x1,int y1,int x2,int y2,int attr)
{
int x,y,addr1,addr2,ch_att;
SMALL_RECT srctRect;
COORD coordBufCoord;
COORD updateCoordSrc;
ch_att = col_fore[attr & 0xF] | col_back[attr >> 4];
addr1 = y2*updateCoord.X;
@@ -661,15 +795,15 @@ void w32_scroll_dw(int x1,int y1,int x2,int y2,int attr)
srctRect.Left = x1;
srctRect.Bottom = y2;
srctRect.Right = x2;
coordBufCoord.X = x1;
coordBufCoord.Y = y1;
WriteConsoleOutput(
updateCoordSrc.X = x1;
updateCoordSrc.Y = y1;
WriteConsoleOutput(
hNewScreenBuffer,
chiBuffer,
updateCoord,
coordBufCoord,
updateCoordSrc,
&srctRect);
}
@@ -678,7 +812,7 @@ void movetoscreen(void *bf, int offset, int len)
int x;
unsigned char *cbf = (unsigned char *)bf;
SMALL_RECT srctRect;
COORD coordBufCoord;
COORD updateCoordSrc;
len >>= 1;
offset >>= 1;
@@ -691,15 +825,15 @@ void movetoscreen(void *bf, int offset, int len)
srctRect.Left = offset%updateCoord.X;
srctRect.Bottom = (offset+len-1)/updateCoord.X;
srctRect.Right = (offset+len-1)%updateCoord.X;
coordBufCoord.X = srctRect.Left;
coordBufCoord.Y = srctRect.Top;
WriteConsoleOutput(
updateCoordSrc.X = srctRect.Left;
updateCoordSrc.Y = srctRect.Top;
WriteConsoleOutput(
hNewScreenBuffer,
chiBuffer,
updateCoord,
coordBufCoord,
updateCoordSrc,
&srctRect);
}
@@ -716,12 +850,12 @@ void movefromscreen(void *bf, int offset, int len)
}
}
int w32_screenwidth()
int w32_screenwidth(void)
{
return updateCoord.X;
}
int w32_screenheight()
int w32_screenheight(void)
{
return updateCoord.Y;
}
@@ -747,7 +881,7 @@ void resetmouse(void)
/* ----- test to see if the mouse driver is installed ----- */
BOOL mouse_installed(void)
{
return 1;
return TRUE;
}
/* ------ return true if mouse buttons are pressed ------- */
@@ -768,16 +902,25 @@ void get_mouseposition(int *x, int *y)
/* -------- position the mouse cursor -------- */
void set_mouseposition(int x, int y)
{
// #ifdef __REACTOS__
// SetCursorPos(x, y);
// #endif
}
/* --------- display the mouse cursor -------- */
void show_mousecursor(void)
{
#ifdef __REACTOS__
ShowConsoleCursor(hNewScreenBuffer, TRUE);
#endif
}
/* --------- hide the mouse cursor ------- */
void hide_mousecursor(void)
{
#ifdef __REACTOS__
ShowConsoleCursor(hNewScreenBuffer, FALSE);
#endif
}
/* --- return true if a mouse button has been released --- */

View File

@@ -19,7 +19,11 @@ static int root;
FILE *OpenHelpFile(const char *fn, const char *md)
{
int treect, i;
#if defined(_WIN32) && defined(__REACTOS__)
char helpname[MAX_PATH];
#else
char helpname[65];
#endif
/* Get the name of the help file */
BuildFileName(helpname, fn, ".hlp");

View File

@@ -28,11 +28,15 @@
#endif
#include <ctype.h>
#include <io.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <setjmp.h>
#if defined(_WIN32) && defined(__REACTOS__)
#define MAX_PATH 260
#endif
#if defined(_WIN32) || defined(__DJGPP__)
#define far
#define near
@@ -60,7 +64,7 @@ typedef enum {FALSE, TRUE} BOOL;
#define DOUBLETICKS 5
#ifdef _WIN32
#define MAXTEXTLEN (16*1024*1024) /* 16 MB is enought! */
#define MAXTEXTLEN (16*1024*1024) /* 16 MB is enough! */
#else
#define MAXTEXTLEN 65000U /* maximum text buffer */
#endif

View File

@@ -9,6 +9,13 @@
#include "dflat.h"
#ifdef __REACTOS__
#define countof(x) (sizeof(x)/sizeof(x[0]))
/* See system.h */
void fix_mbar(MBAR *mbar);
#endif
/* D E F I N E S ///////////////////////////////////////////////////////// */
#define CHARSLINE 80
@@ -19,6 +26,9 @@
extern DBOX PrintSetup;
char DFlatApplication[] = "Edit";
static char Untitled[] = "Untitled";
#ifdef __REACTOS__
static unsigned int untitledCount = 0;
#endif
static int wndpos, LineCtr, CharCtr;
static char *ports[] = {
"Lpt1", "Lpt2", "Lpt3",
@@ -118,7 +128,13 @@ int main(int argc, char *argv[])
fix_mbar(&MainMenu);
#ifdef __REACTOS__
// Use an empty title string for CreateWindow() to not add HASTITLEBAR.
wnd = CreateWindow(APPLICATION, NULL/*"FreeDOS Edit"*/, 0, 0, -1, -1, &MainMenu, NULL, MemoPadProc, /*MOVEABLE | SIZEABLE | HASBORDER | MINMAXBOX |*/ HASSTATUSBAR);
SendMessage(wnd, MAXIMIZE, 0, 0); /* Put the application window maximized */
#else
wnd = CreateWindow(APPLICATION, "FreeDOS Edit", 0, 0, -1, -1, &MainMenu, NULL, MemoPadProc, MOVEABLE | SIZEABLE | HASBORDER | MINMAXBOX | HASSTATUSBAR);
#endif
LoadHelpFile(DFlatApplication);
SendMessage(wnd, SETFOCUS, TRUE, 0);
if (cfg.loadblank)
@@ -261,7 +277,7 @@ static int MemoPadProc(WINDOW wnd,MESSAGE msg,PARAM p1,PARAM p2)
" D-Flat application published \n"
" in Dr. Dobb's Journal. \n"
" \n"
" ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ \n"
" ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ \n"
" \n"
"FreeDOS Edit is a clone of MS-DOS\n"
"editor for the FreeDOS Project \n"
@@ -330,6 +346,11 @@ static void OpenPadWindow(WINDOW wnd, char *FileName,char *NewFileName)
#if !defined(_WIN32)
char *ermsg;
#endif
#ifdef __REACTOS__
/* Buffer big enough to hold the NULL-terminated string L"4294967295",
* corresponding to the literal 0xFFFFFFFF (MAXULONG) in decimal. */
char newUntitled[countof(Untitled) + countof(" (4294967295)")];
#endif
if (strcmp(FileName, Untitled))
{
@@ -354,6 +375,18 @@ static void OpenPadWindow(WINDOW wnd, char *FileName,char *NewFileName)
}
#endif
}
#ifdef __REACTOS__
else if (NewFileName == NULL)
{
untitledCount++;
if (untitledCount > 1)
{
sprintf(newUntitled, "%s (%lu)", Untitled, untitledCount);
Fname = newUntitled;
}
// else { Fname = Untitled; }
}
#endif
wwnd = WatchIcon();
wndpos += 2;
@@ -386,10 +419,19 @@ static void OpenPadWindow(WINDOW wnd, char *FileName,char *NewFileName)
}
else
{
#ifdef __REACTOS__
// assert(wnd1->extension == NULL);
if (strcmp(FileName, Untitled))
{
wnd1->extension = DFmalloc(strlen(FileName)+1);
strcpy(wnd1->extension, FileName);
}
#else
if (strcmp(FileName,Untitled) || wnd1->extension == NULL)
wnd1->extension = DFmalloc(strlen(FileName)+1);
strcpy(wnd1->extension, FileName);
#endif
LoadFile(wnd1); /* Only load if not a new file */
}
@@ -406,7 +448,11 @@ static void LoadFile(WINDOW wnd)
unsigned int recptr = 0;
FILE *fp;
#ifdef __REACTOS__
if (wnd->extension == NULL)
#else
if (!strcmp(wnd->extension, Untitled)) /* Not a real file load */
#endif
{
SendMessage(wnd, SETTEXT, (PARAM) "", 0);
return;
@@ -545,6 +591,10 @@ static void SaveFile(WINDOW wnd, int Saveas)
{
if (SaveAsDialogBox("*.*", NULL, FileName))
{
#ifdef __REACTOS__
if (wnd->extension == NULL)
untitledCount--;
#endif
if (wnd->extension != NULL)
free(wnd->extension);
@@ -725,6 +775,11 @@ static int EditorProc(WINDOW wnd,MESSAGE msg,PARAM p1,PARAM p2)
wnd->TextChanged=FALSE;
}
#ifdef __REACTOS__
if (wnd->extension == NULL)
untitledCount--;
#endif
if (wnd->TextChanged)
{
char *cp = DFmalloc(80+strlen(GetTitle(wnd)));

View File

@@ -52,9 +52,17 @@ static void BuildMenuMsg(WINDOW wnd, PARAM p1)
GetText(wnd)=DFrealloc(GetText(wnd), strlen(GetText(wnd))+5);
memmove(GetText(wnd)+offset+4, GetText(wnd)+offset, strlen(GetText(wnd))-offset+1);
CopyCommand(GetText(wnd)+offset,ActiveMenu->Title,FALSE, wnd->WindowColors [STD_COLOR] [BG]);
#ifdef __REACTOS__
menu[mctr].x1=offset-1;
#else
menu[mctr].x1=offset;
#endif
offset += strlen(ActiveMenu->Title)+(3+MSPACE);
#ifdef __REACTOS__
menu[mctr].x2=offset-MSPACE+1;
#else
menu[mctr].x2=offset-MSPACE;
#endif
cp=strchr(ActiveMenu->Title, SHORTCUTCHAR);
if (cp)
menu[mctr].sc=tolower(*(cp+1));

View File

@@ -16,8 +16,12 @@ DEFMENU(MainMenu)
SELECTION("~Print", ID_PRINT, 0, INACTIVE)
SELECTION("P~rinter setup...", ID_PRINTSETUP, 0, 0)
SEPARATOR
#ifndef _WIN32 // doesn't have much sense in this enviroment
#ifdef INCLUDE_SHELLDOS
#ifndef _WIN32
SELECTION("~DOS Shell", ID_DOS, 0, 0)
#else
SELECTION("S~hell", ID_DOS, 0, 0)
#endif
#endif
SELECTION("E~xit", ID_EXIT, ALT_X, 0)
ENDPOPDOWN

View File

@@ -105,7 +105,11 @@ static BOOL KeyboardMsg(WINDOW wnd, PARAM p1, PARAM p2)
if (x < SCREENWIDTH-1)
x++;
break;
#ifdef __REACTOS__
case LARROW:
#else
case BS:
#endif
if (x)
--x;
break;

View File

@@ -30,7 +30,11 @@ int RadioButtonProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
case KEYBOARD:
if ((int)p1 != ' ')
break;
#ifdef __REACTOS__
case BUTTON_RELEASED:
#else
case LEFT_BUTTON:
#endif
SetRadioButton(db, ct);
break;
default:

View File

@@ -29,7 +29,11 @@ int StatusBarProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
statusbar = DFcalloc(1, WindowWidth(wnd)+1);
memset(statusbar, ' ', WindowWidth(wnd));
*(statusbar+WindowWidth(wnd)) = '\0';
#ifdef __REACTOS__
strncpy(statusbar+1, "~F1=Help ³", 9);
#else
strncpy(statusbar+1, "F1=Help Ý", 9);
#endif
if (wnd->text)
{
int len = min(strlen(wnd->text), WindowWidth(wnd)-9);

View File

@@ -14,8 +14,8 @@
#ifdef _WIN32
#include "dir_w32.h"
#include "country_w32.h"
int w32_screenwidth();
int w32_screenheight();
int w32_screenwidth(void);
int w32_screenheight(void);
#define SCREENWIDTH w32_screenwidth()
#define SCREENHEIGHT w32_screenheight()
void init_videomode(void);

View File

@@ -4,6 +4,7 @@
BOOL ClipString;
/* In console_w32.c */
void movefromscreen(void *bf, int offset, int len);
void movetoscreen(void *bf, int offset, int len);

View File

@@ -57,8 +57,13 @@ WINDOW WatchIcon(void)
WINDOW wnd;
SendMessage(NULL, CURRENT_MOUSE_CURSOR, (PARAM) &mx, (PARAM) &my);
#ifdef __REACTOS__
wnd = CreateWindow(BOX, NULL, mx, my, 3, 5, NULL,NULL,
WatchIconProc, VISIBLE /*| HASBORDER */| NOCLIP | SAVESELF);
#else
wnd = CreateWindow(BOX, NULL, mx, my, 3, 5, NULL,NULL,
WatchIconProc, VISIBLE | HASBORDER | SHADOW | SAVESELF);
#endif
return wnd;
}