void pre_load_object() { SDL_Event event; if(!current_object.object_mem) { load_object=1;//tell the file open save function to load an object, not a terrain DoFileOpenSave (0); while (SDL_PollEvent (&event)); //clears all the events } }
LRESULT CALLBACK EditProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ char bstr[MAX_PATH]; char *p,c; int i,k,n,o,r,f; POINT pt; struct edvars *ev; r = 0; //if (domove(GetParent(hwnd),message,wParam,lParam)) return 0; switch (message) { case WM_COPYDATA: if (0x4F4E4242 == ((PCOPYDATASTRUCT)lParam)->dwData) { char buff[MAX_PATH]; int line_nr; const char *file = (const char*)((PCOPYDATASTRUCT)lParam)->lpData; getfile(buff, file, &line_nr); set_currentdir(buff); LoadFile(buff); if (line_nr) { ed_cmd(EK_GOTOLINE,line_nr-1); //ed_cmd(EK_MARK,lpos,imin(lpos+1,nextline(lpos,1))); } r = TRUE; goto p0r; } return bbn_receive_data(hwnd, lParam); default: if (bb_broadcast_msg == message && message) { if (bb_register(hwnd) && bb_getstyle(hwnd)) goto reconfig1; return 0; } break; case BB_RECONFIGURE: if (bb_getstyle(hwnd)) goto reconfig1; return 0; reconfig1: bb_close_dlg(); makedlgfont(); reconfig: zy0 = title_h + FRM-1; setsize(hwnd); new_back(); InvalidateRect(hwnd, NULL, FALSE); return 0; case BB_SETSTYLESTRUCT: { StyleStruct *d = (StyleStruct *)wParam; StyleStruct *s = (StyleStruct *)lParam; memset(d, 0, sizeof *d); memcpy(d, s, sizeof *d); break; } case BB_SETSTYLE: { char *d = (char *)wParam; char *s = (char *)lParam; strcpy(d, s); break; } case WM_CREATE: zy0 = title_h + FRM-1; setsize(ewnd=hwnd); dragC = LoadCursor(hInst,MAKEINTRESOURCE(101)); dragCp = LoadCursor(hInst,MAKEINTRESOURCE(102)); pointC = hCurs = LoadCursor(NULL,IDC_ARROW); init_edit(hwnd); DragAcceptFiles(hwnd,TRUE); if (false == bb_register(hwnd) || false == bb_getstyle(hwnd)) readstyle(defstyle); goto reconfig1; case WM_DROPFILES: { POINT pt; HDROP hDrop = (HDROP)wParam; int n,f; ev=edp; f=0; GetCursorPos(&pt); if (GetAsyncKeyState(VK_CONTROL)<0) f=1; if (GetAsyncKeyState(VK_SHIFT)<0) f=2; if (f) ScreenToClient(hwnd,&pt); for (i=-1, k=0; i<k; i++) { n=DragQueryFile (hDrop, i, p=bstr, 255); if (i<0) { k=n; } else if (f==0) { LoadFile(p); } else if (f==2) { if (readstyle(p)) { CopyFile(p, defstyle, FALSE); } break; } else { if (i == 0 && -1 == getmoupos(pt.x ,pt.y)) break; ed_cmd(EK_SETVAR); ed_cmd(EK_INSERT, p); ed_cmd(KEY_RET); } } DragFinish(hDrop); SetForegroundWindow(hwnd); if (f==0) goto showf; if (f==2) goto reconfig1; goto p0; } case WM_QUERYENDSESSION: return (1 == QueryDiscard(hwnd,1)); case WM_ENDSESSION: { //void savecfg(void); savecfg(); return 0; } case WM_DESTROY: exit_edit(); DragAcceptFiles(hwnd,FALSE); bb_unregister(hwnd); PostQuitMessage(0); return 0 ; case WM_ACTIVATE: i=LOWORD(wParam); if (i==WA_ACTIVE) clickflag=0; return 0; case WM_ACTIVATEAPP: if (wParam) { clickflag=2; } return 0; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: if (alt_f) alt_f=2; case WM_MOUSEMOVE: #if 0 { static int wm; i = (short)HIWORD(lParam)/2; n = wm; wm = i; wParam = MAKELPARAM(0,(n-i)*30); goto mwhl; } #endif case WM_LBUTTONDBLCLK: case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_MBUTTONDOWN: if (drag==0 && domove (hwnd, message, wParam, lParam)) return 0; do_mouse(hwnd, wParam, lParam, message); if (message==WM_MOUSEMOVE && 0==(wParam & (MK_LBUTTON | MK_RBUTTON))) return 0; goto p0; case WM_TIMER: if (wParam==2) { resetmsg(hwnd); goto p0; } if (wParam==4) { mousewheelaccu=0; t0: KillTimer(hwnd, wParam); return 0; } GetCursorPos(&pt); ScreenToClient(hwnd,&pt); o=getmoupos(pt.x ,pt.y); if (o!=tcmd) { settimer(hwnd, o, SCROLL_INTERVAL); return 0; } if (tcmd==0) goto t0; c=ltup; ltup=0; ed_cmd(tcmd); ed_cmd(tcmd); upd=1; ltup=c; k=GetAsyncKeyState(VK_SHIFT)&0x8000; domarking(k!=0 || (0==moumrk && 0==drag)); goto p0; case WM_SIZE: if (SIZE_MINIMIZED == wParam) return 0; if (edp) upd=1; ed_cmd(EK_SIZE); new_back(); case WM_MOVE: setsize(hwnd); goto p0; /* case WM_WINDOWPOSCHANGED: ewx0 = ((LPWINDOWPOS) lParam)->x; ewy0 = ((LPWINDOWPOS) lParam)->y; ewxl = ((LPWINDOWPOS) lParam)->cx; ewyl = ((LPWINDOWPOS) lParam)->cy; cfg_f |= 1; break; //process wm_move/wm_size case WM_WINDOWPOSCHANGING: SnapWindowToEdge((WINDOWPOS*)lParam, 10, 0); setsize(hwnd); return 0; */ case WM_VSCROLL: vscroll(wParam); goto p0; case WM_HSCROLL: hscroll(wParam); goto p0; case WM_SETFOCUS: k_alt = 0>GetAsyncKeyState(VK_MENU); k_shft= 0>GetAsyncKeyState(VK_SHIFT); k_ctrl= 0>GetAsyncKeyState(VK_CONTROL); CreateCaret(hwnd,NULL,My_CaretSize,zy); caret=1; checkftime(hwnd); goto f1; case WM_KILLFOCUS: DestroyCaret(); caret=0; f1: if (edp) upd=1; goto p0; p0: r=0; p0r: set_update(hwnd); return r; case WM_ERASEBKGND: return 1; case WM_PAINT: paint_window (hwnd); return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case CMD_HELP: #if 0 bbnote_help(); return 0; #else if (fileexist(set_my_path(bstr, "bbnote.txt"))) LoadFile(bstr); else if (fileexist(set_my_path(bstr, "docs/bbnote.txt"))) LoadFile(bstr); goto p0; #endif case CMD_EXIT: goto quit; case CMD_MENU_2: filemenu: if (ed0) { struct edvars *e = ed0; struct strl *s = NULL; while (e) { char temp[MAX_PATH]; sprintf(temp, "&%s", fname(e->sfilename)); appendstr(&s, temp); e = e->next; } bb_file_menu (hwnd, lParam, s); } return 0; case CMD_MENU_1: bb_menu(hwnd, lParam); return 0; case CMD_COLOR: goto reconfig; case CMD_UPD: settitle(); if (edp) upd=1; goto p0; case CMD_ZOOM: zoom: ShowWindow(hwnd, IsZoomed(hwnd) ? SW_SHOWNORMAL : SW_MAXIMIZE); return 0; case CMD_SEARCH: search: if (edp) bb_search_dialog(hwnd); return 0; case CMD_CLOSE: closefile: if (edp) { if (1 != QueryDiscard_1(hwnd, 1)) goto p0; if (ed0->next==NULL) { extern HWND mwnd; SendMessage(mwnd, WM_KEYDOWN, VK_ESCAPE, 0); //DestroyWindow(mwnd); } CloseFile(); } goto p0; case CMD_OPEN: openfile: ev=edp; DoFileOpenSave(hwnd, 0); showf: if (ev==NULL || ev->next) { edp = ev ? ev->next : ed0; settitle(); } goto p0; case CMD_RELOAD: reload: if (edp) f_reload(1); goto p0; case CMD_LIST: lParam = 2; goto filemenu; case CMD_NEW: newfile: NewFile(); goto p0; case CMD_SAVE: savefile: if (edp) DoFileOpenSave(hwnd, 2); goto p0; case CMD_SAVEAS: if (edp!=NULL) DoFileOpenSave(hwnd, 1); break; case CMD_SAVEALL: //saveall: return QueryDiscard(hwnd, 0); case CMD_UNDO: ed_cmd(KEY_C_Z); goto p0; case CMD_REDO: ed_cmd(KEY_CS_Z); goto p0; case CMD_ABOUT: oyncan_msgbox( VERSION_STRING "\n" "\nediting with style" "\n04/2003 by grischka" "\n" "\[email protected]" , NULL, 1); return 0; case CMD_OPTIONS: goto config; case CMD_INFO: resetmsg(hwnd); p=(char*)lParam; if (p[0]==1) p++; else infoflg=1,infotimer=SetTimer(hwnd,2,666,NULL); strcpy(infomsg,p); if (edp) upd=1; goto p0; case CMD_FILECHG: { struct edvars *p=edp; edp=(struct edvars*)lParam; settitle(); set_update(hwnd); f_reload(0); edp=p; settitle(); goto p0; } default: i = LOWORD(wParam); if (i>=CMD_FILE && i< CMD_FILE_M) { struct edvars *p=ed0; i-=CMD_FILE; for (;i && p!=NULL; p=p->next,i--); if (p) { //edp = p; settitle(); insfile(p); goto p0; } return 0; } break; } break; quit: if (1 == QueryDiscard(hwnd, 1)) DestroyWindow(hwnd); return 0; case WM_SYSKEYDOWN: f=3; goto k1; case WM_SYSKEYUP: f=2; goto k1; case WM_KEYUP: if (wParam==VK_CONTROL && drag==3) setdragc(2); f=0; goto k1; case WM_KEYDOWN: if (wParam==VK_CONTROL && drag==2) setdragc(3); if (wParam==VK_SCROLL) { scroll_lock^=1; goto p0; } f=1; k1: n=LOWORD(wParam); #if 0 sprintf(bstr,"key %d stat %d",n,f); if (n!=VK_MENU) MessageBox(NULL, bstr, "", MB_OK|MB_TOPMOST|MB_SETFOREGROUND); #endif n=trans_keys(n, f); //if (0==n) goto p0; if (0==n) return 0; if (n>=2110 && n<=2117) { vmark=k_alt!=0; domarking(1); ed_cmd(n-100); domarking(1); goto p0; } switch (n) { case KEY_F8: return 0; case KEY_A_RIGHT: case KEY_F6: nextfile(); goto p0; case KEY_A_LEFT: case KEY_C_F6: prevfile(); goto p0; case KEY_F10: goto zoom; case KEY_F3: case KEY_C_F: goto search; case KEY_C_F4: goto closefile; case KEY_C_O: goto openfile; //case KEY_A_F3: goto reload; case KEY_C_N: goto newfile; case KEY_C_L: lParam = 0; goto filemenu; case KEY_F4: QueryDiscard(hwnd, 0); bb_reconfig(); return 0; case KEY_S_F4: if (IDOK == oyncan_msgbox("Do you want to write all files?", "", 1+8)) QueryDiscard(hwnd, 4); return 0; case KEY_C_S: goto savefile; case KEY_A_F4: goto quit; case KEY_A_F2: config: n = tabs; bb_config_dialog(hwnd); if (n!=tabs) goto reload; return 0; case KEY_ESC: if (drag==0) goto quit; dragmove=0; do_mouse(hwnd, 0,0,WM_LBUTTONUP); goto p0; case KEY_UP: case KEY_DOWN: if (scroll_lock) n+=200; goto defkey; case KEY_LEFT: case KEY_RIGHT: if (scroll_lock) n=(n^1)+204; goto defkey; } defkey: domarking(0); ed_cmd(n); i=n; if (i!=KEY_C_A && i!=KEY_C_U && i!=KEY_C_7 && i!=KEY_C_8 && i!=KEY_C_9 && i!=KEY_C_0 && i!=KEY_TAB && i!=KEY_S_TAB ) unmark(); goto p0; case WM_MOUSEWHEEL: i = mousewheelaccu + mousewheelfac * (short)HIWORD(wParam); while (i < -300) ed_cmd(KEY_C_DOWN), i+=600; while (i > 300) ed_cmd(KEY_C_UP), i-=600; mousewheelaccu=i; unmark(); SetTimer(hwnd, 4, 200, NULL); goto p0; case WM_NCPAINT: return 0; case WM_CHAR: n = LOWORD(wParam); if (n<32||n==127) return 0; resetmsg(hwnd); ed_cmd(EK_CHAR, n); goto p0; case CMD_GOTOLINE: ed_cmd(EK_GOTOLINE,wParam-1); ed_cmd(EK_MARK,lpos,imin(lpos+1,nextline(lpos,1))); lmf=2; goto p0; case CMD_LOADFILE: r=LoadFile((char*)wParam); goto p0r; case CMD_NSEARCH: resetmsg(hwnd); if (wParam&8) { ed_cmd(EK_REPLACE,(char *)lParam); if (wParam&1) ed_cmd(EK_GOTO,fpos+strlen((char*)lParam)); goto p0; } unmark(); if (wParam!=0) { struct sea *s=(struct sea *)lParam; struct edvars *ev0; for (ev0=edp;;) { r=ed_search(s); if (r || 0==(s->sf&128)) break; s->sf &= ~4; if (s->sf & 1) { if (edp->next==NULL) break; nextfile(); s->from=0; continue; } if (s->sf & 2) { if (edp==ed0) break; prevfile(); s->from=flen; continue; }} if (r<=0) { edp=ev0; settitle(); } else { ed_cmd(KEY_HOME); ed_cmd(EK_MARK,s->a,s->e); ed_cmd(EK_GOTO,s->a); } } goto p0r; } return DefWindowProc (hwnd, message, wParam, lParam) ; }