diff --git a/pc/ChangeLog b/pc/ChangeLog index 3931cd533..11d15751e 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,14 @@ +Fri May 8 10:49:21 1998 Pavel Roskin + + * Makefile.PC, Makefile.MIN: support for custom extension + for compiled resourses + + * key_nt.c: Minor changes for MinGW + + * mc.rc: WindRes support + + * slint_pc.c: support for syntax highlighting + Fri May 1 17:33:11 1998 Pavel Roskin * chmod.c: Updated call to update_panels() diff --git a/pc/Makefile b/pc/Makefile index 4f3ff1cfc..1ed380e77 100644 --- a/pc/Makefile +++ b/pc/Makefile @@ -14,7 +14,7 @@ FILES = BUGS Makefile Makefile.BC2 Makefile.BC5 Makefile.EMX Makefile.MIN \ config.h cons_nt.c cons_os2.c dirent.h dirent_nt.c dirent_os2.c \ drive.c drive.h key_nt.c key_os2.c mc.def mc.rc mc_nt.ico \ mc_os2.ico slint_pc.c trace_nt.c trace_nt.h util_nt.c \ - util_os2.c util_win32.c util_win32.h util_winnt.c + util_os2.c util_win32.c util_win32.h util_winnt.c ChangeLog FILESSYS = sys/param.h sys/time.h diff --git a/pc/Makefile.MIN b/pc/Makefile.MIN index 09451ced5..4bf71f5e0 100644 --- a/pc/Makefile.MIN +++ b/pc/Makefile.MIN @@ -18,6 +18,7 @@ EXE_PLACE=-o # Just comment RSC out if you have problems with resources RSC=windres.exe RES_PLACE=-o +RES_SUFFIX=o # ---- Compiler-specific optional stuff MC_MISC_CFLAGS= @@ -31,7 +32,7 @@ SPECIFIC_MC_CFLAGS=-g -O0 $(MC_MISC_CFLAGS) SPECIFIC_MC_LFLAGS_EXTRA= SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS) SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS) -RC_DEFINES=-O coff --define _DEBUG +RC_DEFINES=--define WINDRES --define _DEBUG else # ---- Release build OBJS_DIR=release @@ -41,7 +42,7 @@ SPECIFIC_MC_CFLAGS=-O2 $(MC_MISC_CFLAGS) SPECIFIC_MC_LFLAGS_EXTRA= SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS) SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS) -RC_DEFINES=-O coff --define RELEASE=$(RELEASE) +RC_DEFINES=--define WINDRES --define RELEASE=$(RELEASE) endif # ---- Compiler independent defines diff --git a/pc/Makefile.PC b/pc/Makefile.PC index f6ad83d6b..4392af2ed 100644 --- a/pc/Makefile.PC +++ b/pc/Makefile.PC @@ -42,8 +42,6 @@ MCEDIT_INCLUDES=-I$(MC_PC_DIR) -I$(MC_SRC_DIR)/.. -I$(SLANG_SRC_DIR) CFLAGS=$(SPECIFIC_MC_CFLAGS) $(MC_INCLUDES) $(MC_DEFINES) -c SLANG_CFLAGS=$(SPECIFIC_SLANG_CFLAGS) $(SLANG_INCLUDES) $(SLANG_DEFINES) -c MCEDIT_CFLAGS=$(SPECIFIC_MCEDIT_CFLAGS) $(MCEDIT_INCLUDES) $(MCEDIT_DEFINES) -c -RSC_FLAGS=$(RES_PLACE)$(OBJS_DIR)/mc.res $(RC_DEFINES) - all: object-dirs mc @@ -163,10 +161,16 @@ MCEDIT_OBJS=$(addprefix $(MCEDIT_OBJS_DIR)/, \ $(patsubst %.c,%.$(OBJ_SUFFIX),$(MCEDIT_SRCS))) ifdef RSC -MC_RES=$(OBJS_DIR)/mc.res + +ifndef RES_SUFFIX +RES_SUFFIX=res +endif # RES_SUFFIX + +MC_RES=$(OBJS_DIR)/mc.$(RES_SUFFIX) + +$(MC_RES): $(MC_PC_DIR)/mc.rc $(MC_PC_DIR)/mc_nt.ico $(MC_PC_DIR)/config.h ../VERSION + $(RSC) $(RES_PLACE)$(MC_RES) $(RC_DEFINES) $(MC_PC_DIR)/mc.rc + else MC_RES= -endif - -$(OBJS_DIR)/mc.res: $(MC_PC_DIR)/mc.rc $(MC_PC_DIR)/mc_nt.ico $(MC_PC_DIR)/config.h ../VERSION - $(RSC) $(RSC_FLAGS) $(MC_PC_DIR)/mc.rc +endif # !RSC diff --git a/pc/key_nt.c b/pc/key_nt.c index b39d3dd5e..d6d1091d5 100644 --- a/pc/key_nt.c +++ b/pc/key_nt.c @@ -176,7 +176,11 @@ int get_key_code (int no_delay) break; vkcode = ir.Event.KeyEvent.wVirtualKeyCode; +#ifndef __MINGW32__ ch = ir.Event.KeyEvent.uChar.AsciiChar; +#else + ch = ir.Event.KeyEvent.AsciiChar; +#endif dwSaved_ControlState = ir.Event.KeyEvent.dwControlKeyState; j = translate_key_code (ch, vkcode); if (j) diff --git a/pc/mc.rc b/pc/mc.rc index 912bfcb46..98ea9d3b4 100644 --- a/pc/mc.rc +++ b/pc/mc.rc @@ -1,15 +1,19 @@ - -#include "windows.h" -#include "winver.h" -#include "config.h" - +#ifdef WINDRES +# include "../VERSION" +#else +# include "windows.h" +# include "winver.h" +# include "config.h" +#endif /* English (U.S.) resources */ #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 +#ifndef WINDRES LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#endif #pragma code_page(1252) #endif /* _WIN32 */ diff --git a/pc/slint_pc.c b/pc/slint_pc.c index abe177a48..d1b709abf 100644 --- a/pc/slint_pc.c +++ b/pc/slint_pc.c @@ -139,12 +139,6 @@ void vline (int character, int len) } } -void init_pair (int index, char *foreground, char *background) -{ - SLtt_set_color (index, "", foreground, background); -} - - int has_colors () { /* No terminals on NT, make default color */ @@ -218,3 +212,55 @@ void slang_set_raw_mode (void) return; } +int max_index = 0; + +void +init_pair (int index, char *foreground, char *background) +{ + + SLtt_set_color (index, "", foreground, background); + if (index > max_index) + max_index = index; +} + +int +alloc_color_pair (char *foreground, char *background) +{ + init_pair (++max_index, foreground, background); + return max_index; +} + +int +try_alloc_color_pair (char *fg, char *bg) +{ + static struct colors_avail { + struct colors_avail *next; + char *fg, *bg; + int index; + } *p, c = + { + 0, 0, 0, 0 + }; + + c.index = NORMAL_COLOR; + p = &c; + for (;;) { + if (((fg && p->fg) ? !strcmp (fg, p->fg) : fg == p->fg) != 0 + && ((bg && p->bg) ? !strcmp (bg, p->bg) : bg == p->bg) != 0) + return p->index; + if (!p->next) + break; + p = p->next; + } + p->next = malloc (sizeof (c)); + p = p->next; + p->next = 0; + p->fg = fg ? strdup (fg) : 0; + p->bg = bg ? strdup (bg) : 0; + if (!fg) + fg = "white"; + if (!bg) + bg = "blue"; + p->index = alloc_color_pair (fg, bg); + return p->index; +} diff --git a/pc/util_win32.c b/pc/util_win32.c index aecab175e..6c092b03c 100644 --- a/pc/util_win32.c +++ b/pc/util_win32.c @@ -96,6 +96,8 @@ int win32_GetVersionEx () int win32_GetEXEType (const char* a_szFileName) { +/* FIXME: MinGW cannot compile this code */ +#ifndef __MINGW32__ HANDLE hImage; DWORD dwDumm; DWORD SectionOffset; @@ -177,6 +179,9 @@ int win32_GetEXEType (const char* a_szFileName) win32Trace(("Unknown type %u.\n", image_optional_header.Subsystem)); return EXE_Unknown; } +#else + return EXE_Unknown; +#endif /* !__MINGW32__ */ } diff --git a/slang/slw32tty.c b/slang/slw32tty.c index 938e8bd49..68b75feb7 100644 --- a/slang/slw32tty.c +++ b/slang/slw32tty.c @@ -203,7 +203,11 @@ unsigned int SLsys_getkey (void) return 0; } if (record.EventType == KEY_EVENT && record.Event.KeyEvent.bKeyDown) { +#ifndef __MINGW32__ return record.Event.KeyEvent.uChar.AsciiChar; +#else + return record.Event.KeyEvent.AsciiChar; +#endif } } /* ReadFile(hStdin, &key, 1, &bytesRead, NULL); */