allow ctrl+s to work properly.

if someone double-clicks a src file somewhere, switch to that directory and compile with that file. hurrah for file associations.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4814 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2014-12-31 07:43:04 +00:00
parent b0f0fc80bb
commit dd57aa60aa
2 changed files with 63 additions and 21 deletions

View File

@ -507,6 +507,7 @@ HWND projecttree;
HWND search_name;
HWND search_gotodef;
HWND search_grep;
HACCEL accelerators;
FILE *logfile;
@ -791,6 +792,7 @@ enum {
IDM_GREP,
IDM_GOTODEF,
IDM_SAVE,
IDM_RECOMPILE,
IDM_FIND,
IDM_QUIT,
IDM_UNDO,
@ -845,7 +847,7 @@ void QueryOpenFile(void)
SetCurrentDirectory(oldpath);
}
//IDM_ stuff that needs no active menu
//IDM_ stuff that needs no active window
void GenericMenu(WPARAM wParam)
{
switch(LOWORD(wParam))
@ -854,6 +856,10 @@ void GenericMenu(WPARAM wParam)
QueryOpenFile();
break;
case IDM_RECOMPILE:
buttons[ID_COMPILE].washit = true;
break;
case IDM_ABOUT:
MessageBox(NULL, "FTE QuakeC Compiler ("__DATE__" "__TIME__")\nWritten by Forethought Entertainment.\n\nIt has a few cool features, like a semi-useful IDE.\n\nSupports:\nPrecompiler (with macros)\nArrays\n+= / -= / *= / /= operations.\nSwitch statements\nfor loops\nLots of optimisations.", "About", 0);
break;
@ -1783,15 +1789,15 @@ void EditFile(char *name, int line)
AppendMenu(menu, MF_POPUP, (UINT_PTR)menufile, "&File");
AppendMenu(menu, MF_POPUP, (UINT_PTR)menunavig, "&Navigation");
AppendMenu(menu, MF_POPUP, (UINT_PTR)menuhelp, "&Help");
AppendMenu(menufile, 0, IDM_OPENNEW, "Open &new file ");
AppendMenu(menufile, 0, IDM_OPENNEW, "Open new file ");
AppendMenu(menufile, 0, IDM_SAVE, "&Save ");
// AppendMenu(menufile, 0, IDM_FIND, "&Find");
AppendMenu(menufile, 0, IDM_UNDO, "&Undo Ctrl+Z");
AppendMenu(menufile, 0, IDM_REDO, "&Redo Ctrl+Y");
AppendMenu(menufile, 0, IDM_UNDO, "Undo Ctrl+Z");
AppendMenu(menufile, 0, IDM_REDO, "Redo Ctrl+Y");
AppendMenu(menunavig, 0, IDM_GOTODEF, "Go to definition");
AppendMenu(menunavig, 0, IDM_OPENDOCU, "Open selected file");
AppendMenu(menuhelp, 0, IDM_ABOUT, "About");
AppendMenu(menu, 0, IDM_HIGHTLIGHT, "H&ighlight");
// AppendMenu(menu, 0, IDM_HIGHTLIGHT, "H&ighlight");
}
@ -2865,18 +2871,19 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message,
rootmenu = CreateMenu();
AppendMenu(rootmenu, MF_POPUP, (UINT_PTR)(m = CreateMenu()), "&File");
AppendMenu(m, 0, IDM_OPENNEW, "Open &new file ");
AppendMenu(m, 0, IDM_SAVE, "&Save ");
AppendMenu(m, 0, IDM_OPENNEW, "Open new file ");
AppendMenu(m, 0, IDM_SAVE, "&Save Ctrl+S ");
AppendMenu(m, 0, IDM_RECOMPILE, "&Recompile Ctrl+R ");
// AppendMenu(m, 0, IDM_FIND, "&Find");
AppendMenu(m, 0, IDM_UNDO, "&Undo Ctrl+Z");
AppendMenu(m, 0, IDM_REDO, "&Redo Ctrl+Y");
AppendMenu(m, 0, IDM_UNDO, "Undo Ctrl+Z");
AppendMenu(m, 0, IDM_REDO, "Redo Ctrl+Y");
AppendMenu(rootmenu, MF_POPUP, (UINT_PTR)(m = CreateMenu()), "&Navigation");
AppendMenu(m, 0, IDM_GOTODEF, "Go to definition");
AppendMenu(m, 0, IDM_OPENDOCU, "Open selected file");
AppendMenu(rootmenu, MF_POPUP, (UINT_PTR)(m = windowmenu = CreateMenu()), "&Window");
AppendMenu(m, 0, IDM_CASCADE, "&Cascade");
AppendMenu(m, 0, IDM_TILE_HORIZ, "Tile &Horizontally");
AppendMenu(m, 0, IDM_TILE_VERT, "Tile &Vertically");
AppendMenu(m, 0, IDM_CASCADE, "Cascade");
AppendMenu(m, 0, IDM_TILE_HORIZ, "Tile Horizontally");
AppendMenu(m, 0, IDM_TILE_VERT, "Tile Vertically");
AppendMenu(rootmenu, MF_POPUP, (UINT_PTR)(m = CreateMenu()), "&Help");
AppendMenu(m, 0, IDM_ABOUT, "About");
@ -3043,6 +3050,15 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message,
return 0;
}
static void DoTranslateMessage(MSG *msg)
{
if (!TranslateAccelerator(mainwindow, accelerators, msg))
{
TranslateMessage(msg);
DispatchMessage(msg);
}
}
static LRESULT CALLBACK OutputWindowProc(HWND hWnd,UINT message,
WPARAM wParam,LPARAM lParam)
{
@ -3089,8 +3105,7 @@ void GUIPrint(HWND wnd, char *msg)
{
if (!GetMessage (&wmsg, NULL, 0, 0))
break;
TranslateMessage (&wmsg);
DispatchMessage (&wmsg);
DoTranslateMessage(&wmsg);
}
writing=false;
}
@ -3211,8 +3226,7 @@ int GUIprintf(const char *msg, ...)
{
if (!GetMessage (&wmsg, NULL, 0, 0))
break;
TranslateMessage (&wmsg);
DispatchMessage (&wmsg);
DoTranslateMessage(&wmsg);
}
/*
s = st = buf;
@ -3520,6 +3534,11 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
pbool fl_acc;
unsigned int i;
WNDCLASS wndclass;
ACCEL acceleratorlist[] =
{
{FCONTROL|FVIRTKEY, 'S', IDM_SAVE},
{FCONTROL|FVIRTKEY, 'R', IDM_RECOMPILE}
};
ghInstance= hInstance;
GUI_SetDefaultOpts();
@ -3638,7 +3657,9 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
wndclass.lpszClassName = MDI_WINDOW_CLASS_NAME;
RegisterClass(&wndclass);
mainwindow=CreateWindow(MDI_WINDOW_CLASS_NAME, "FTE QuakeC compiler", WS_OVERLAPPEDWINDOW,
accelerators = CreateAcceleratorTable(acceleratorlist, sizeof(acceleratorlist)/sizeof(acceleratorlist[0]));
mainwindow = CreateWindow(MDI_WINDOW_CLASS_NAME, "FTE QuakeC compiler", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, NULL, NULL, ghInstance, NULL);
if (mdibox)
@ -3724,10 +3745,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
if (!GetMessage (&msg, NULL, 0, 0))
break;
if (!mdibox || !TranslateMDISysAccel(mdibox, &msg))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
DoTranslateMessage(&msg);
}
if (mainwindow)

View File

@ -114,6 +114,7 @@ void GUI_ParseCommandLine(char *args)
int paramlen=0;
int l, p;
char *next;
pbool isfirst = true;
while(*args)
{
while (*args <= ' ' && *args)
@ -305,12 +306,35 @@ void GUI_ParseCommandLine(char *args)
paramlen += l;
}
}
else if (isfirst && *args != '-' && *args != '/')
{
l = 0;
while (*args != ' ' && *args)
progssrcname[l++] = *args++;
progssrcname[l] = 0;
args = strrchr(progssrcname, '\\');
while(args && strchr(args, '/'))
args = strchr(args, '/');
if (args)
{
memcpy(progssrcdir, progssrcname, args-progssrcname);
progssrcdir[args-progssrcname] = 0;
args++;
memmove(progssrcname, args, strlen(args)+1);
SetCurrentDirectoryA(progssrcdir);
*progssrcdir = 0;
}
}
else
{
parameters[paramlen+next-args] = ' ';
paramlen += l;
}
isfirst = false;
args=next;
}
if (paramlen)