1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
|
/*******************************************************************************
* eventhandlers.cpp
*
* This file is part of the CodeMax editor support code.
*
* Author: Christopher J. Cason.
*
* ---------------------------------------------------------------------------
* Persistence of Vision Ray Tracer ('POV-Ray') version 3.7.
* Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd.
*
* POV-Ray is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* POV-Ray is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------------
* POV-Ray is based on the popular DKB raytracer version 2.12.
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/windows/cmedit/eventhandlers.cpp $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
*******************************************************************************/
#include "cmedit.h"
#include "ccodemax.h"
#include "settings.h"
#include "menusupport.h"
#include "eventhandlers.h"
#include "editorinterface.h"
#include "dialogs.h"
#include "..\pvedit.h"
using namespace povwin;
HGLOBAL hPrinterDevMode ;
HGLOBAL hPrinterDevName ;
extern int AutoReload ;
extern int EditorCount ;
extern int AutoSaveDelay ;
extern int NotifyBase ;
extern int PrintPointSize ;
extern int PrintUseBorder ;
extern int PrintTopMargin ;
extern int PrintLeftMargin ;
extern int PrintBottomMargin ;
extern int PrintRightMargin ;
extern bool MessagePaneVisible ;
extern bool CreateBackups ;
extern bool LastOverwrite ;
extern bool UndoAfterSave ;
extern bool PrintUseColor ;
extern bool PrintUseFancyText ;
extern bool PrintUsePageNumbers ;
extern bool PrintUseDateTime ;
extern bool PrintUseFileName ;
extern bool PrintMarginUnitsMetric ;
extern char MessageWinTitle[];
extern HWND hMainWindow ;
extern HWND hStatusWindow ;
extern HWND hTabWindow ;
extern HWND hNotifyWindow ;
extern CCodeMax *Editors [MAX_EDITORS] ;
extern CCodeMax *Editor ;
extern CodemaxColors CJCColours ;
extern CodemaxColors DefaultColours ;
extern HINSTANCE hInstance ;
extern const char *WindowList[MAX_EDITORS + 1];
extern CStdString InsertPath ;
extern CStdString IncludeFilename ;
extern CStdString CommandLine ;
extern CStdString POVRayIniPath ;
extern CStdString DocumentsPath ;
extern CStdStringList RecentFiles ;
extern CStdStringList OlderFiles ;
extern CStdStringList InsertMenuItems ;
extern EditConfigStruct EditConfig ;
void LocateRecentFile (CStdString FileName, CCodeMax *e)
{
int count ;
CStdString str ;
count = RecentFiles.ItemCount () ;
for (int i = 0 ; i < count ; i++)
{
str = RecentFiles [i] ;
if (FileName.CompareNoCase(DecodeFilename(GetNextField(str))) == 0)
{
e->SetLineNo (atoi (GetNextField (str))) ;
e->SetColNo (atoi (GetNextField (str))) ;
e->SetTopLine (atoi (GetNextField (str))) ;
e->SetLanguage ((TLanguage) atoi (GetNextField (str))) ;
e->SetTabSize (atoi (GetNextField (str))) ;
e->SetAutoIndent ((TAutoIndent) atoi (GetNextField (str))) ;
return ;
}
}
count = OlderFiles.ItemCount () ;
for (int i = 0 ; i < count ; i++)
{
str = OlderFiles [i] ;
if (FileName.CompareNoCase(DecodeFilename(GetNextField(str))) == 0)
{
e->SetLineNo (atoi (GetNextField (str))) ;
e->SetColNo (atoi (GetNextField (str))) ;
e->SetTopLine (atoi (GetNextField (str))) ;
e->SetLanguage ((TLanguage) atoi (GetNextField (str))) ;
e->SetTabSize (atoi (GetNextField (str))) ;
e->SetAutoIndent ((TAutoIndent) atoi (GetNextField (str))) ;
}
}
}
void AutoSaveClick (WPARAM wParam, LPARAM lParam)
{
int result = ShowEnterValueDialog ("Time in min (0=off)", 0, 60, AutoSaveDelay / 60) ;
if (result >= 0)
AutoSaveDelay = min (result, 60) * 60 ;
}
void ConstrainCaretClick (WPARAM wParam, LPARAM lParam)
{
EditConfig.SelBoundsEnabled = ToggleMenuItem (CM_CONSTRAINCARET) ;
for (int i = 0 ; i < EditorCount ; i++)
Editors [i]->EnableSelBounds (EditConfig.SelBoundsEnabled) ;
if (IsMenuItemChecked (CM_CONSTRAINCARET))
{
CheckMenuItem (CM_CURSORBEYONDEOL, false) ;
EnableMenuItem (CM_CURSORBEYONDEOL, false) ;
}
else
EnableMenuItem (CM_CURSORBEYONDEOL, true) ;
}
void FindClick ()
{
Editor->Find () ;
EditConfig.WholeWordEnabled = Editor->IsWholeWordEnabled () ;
EditConfig.PreserveCase = Editor->IsPreserveCaseEnabled () ;
EditConfig.CaseSensitive = Editor->IsCaseSensitiveEnabled () ;
EditConfig.RegexpEnabled = Editor->IsRegExpEnabled () ;
}
void ReplaceClick ()
{
Editor->Replace () ;
EditConfig.WholeWordEnabled = Editor->IsWholeWordEnabled () ;
EditConfig.PreserveCase = Editor->IsPreserveCaseEnabled () ;
EditConfig.CaseSensitive = Editor->IsCaseSensitiveEnabled () ;
EditConfig.RegexpEnabled = Editor->IsRegExpEnabled () ;
}
void SaveAsClick (WPARAM wParam, LPARAM lParam)
{
char oldName [_MAX_PATH] ;
TCITEM item ;
EditTagStruct tag ;
tag = Editor->m_Tag ;
strcpy (oldName, tag.LongName) ;
if (!Editor->AskFileName (&tag))
return ;
if (Editor->SaveFile (tag.LongName, !UndoAfterSave) == CODEMAX_SUCCESS)
{
Editor->m_Tag = tag ;
Editor->UpdateFileTime () ;
if (strcmp (tag.LongName, oldName) != 0)
{
item.mask = TCIF_TEXT ;
item.dwState = item.dwStateMask = 0 ;
item.pszText = tag.ShortName ;
TabCtrl_SetItem (hTabWindow, Editor->m_Index + 1, &item) ;
UpdateRecent () ;
Editor->SetLanguageBasedOnFileType () ;
AddToRecent (EncodeFilename(tag.LongName)) ;
}
// pretend the tab has changed so the window caption is updated
SendMessage (hNotifyWindow, WM_COMMAND, NotifyBase + NotifyTabChange, GetFlags ()) ;
}
else
ShowErrorMessage (tag.ShortName, "Failed to save file") ;
}
void PrintClick (void)
{
CodemaxRange range ;
PRINTDLG pd ;
CodemaxPrintEx cmpex ;
memset (&range, 0, sizeof (CodemaxRange)) ;
Editor->GetSel (&range) ;
ZeroMemory (&pd, sizeof (pd)) ;
pd.lStructSize = sizeof (pd) ;
pd.hwndOwner = hMainWindow ;
pd.hDevMode = hPrinterDevMode ;
pd.hDevNames = hPrinterDevName ;
pd.nMinPage = 1 ;
pd.nMaxPage = 9999 ;
pd.lpfnPrintHook = PrintHook ;
pd.lpPrintTemplateName = MAKEINTRESOURCE (IDD_PRINT) ;
pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE | PD_ENABLEPRINTHOOK | PD_ENABLEPRINTTEMPLATE ;
if (memcmp (&range.End, &range.Start, sizeof (CodemaxPos)) == 0)
pd.Flags |= PD_NOSELECTION ;
else
pd.Flags |= PD_SELECTION ;
pd.hInstance = hInstance ;
if (PrintDlg (&pd))
{
hPrinterDevMode = pd.hDevMode ;
hPrinterDevName = pd.hDevNames ;
ZeroMemory (&cmpex, sizeof (cmpex)) ;
// Editor->Print() will delete the DC for us
cmpex.DC = pd.hDC ;
cmpex.Flags = CODEMAX_PRINT_HDC ;
if (PrintUseColor)
cmpex.Flags |= CODEMAX_PRINT_COLOR ;
if (PrintUseFancyText)
cmpex.Flags |= CODEMAX_PRINT_RICHFONTS ;
if (PrintUseBorder)
cmpex.Flags |= CODEMAX_PRINT_BORDERTHIN << (PrintUseBorder - 1) ;
if (PrintUseDateTime)
cmpex.Flags |= CODEMAX_PRINT_DATETIME ;
if (PrintUsePageNumbers)
cmpex.Flags |= CODEMAX_PRINT_PAGENUMS ;
if (PrintUseFileName)
{
cmpex.Flags |= CODEMAX_PRINT_FILENAME ;
cmpex.FileName = Editor->m_Tag.ShortName ;
}
if ((pd.Flags & PD_SELECTION) != 0)
cmpex.Flags |= CODEMAX_PRINT_SELECTION ;
if (PrintPointSize != 0)
cmpex.PointSize = PrintPointSize ;
if ((pd.Flags & PD_PAGENUMS) != 0)
{
cmpex.Flags |= CODEMAX_PRINT_PAGERANGE ;
cmpex.FirstPage = pd.nFromPage ;
cmpex.LastPage = pd.nToPage ;
}
if (PrintTopMargin != -1 && PrintBottomMargin != -1 && PrintLeftMargin != -1 && PrintRightMargin != -1)
{
if (PrintMarginUnitsMetric)
{
// convert hundredths of a millimeter to thousandths of an inch
cmpex.Margin.left = PrintLeftMargin * 1000 / 2630 ;
cmpex.Margin.right = PrintRightMargin * 1000 / 2630 ;
cmpex.Margin.top = PrintTopMargin * 1000 / 2630 ;
cmpex.Margin.bottom = PrintBottomMargin * 1000 / 2630 ;
}
else
{
cmpex.Margin.left = PrintLeftMargin ;
cmpex.Margin.right = PrintRightMargin ;
cmpex.Margin.top = PrintTopMargin ;
cmpex.Margin.bottom = PrintBottomMargin ;
}
}
Editor->Print (&cmpex) ;
}
}
void PageSetupClick (void)
{
PAGESETUPDLG psd ;
ZeroMemory (&psd, sizeof (psd)) ;
psd.lStructSize = sizeof (psd) ;
psd.hwndOwner = hMainWindow ;
psd.hDevMode = hPrinterDevMode ;
psd.hDevNames = hPrinterDevName ;
psd.Flags = PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGESETUPTEMPLATE ;
if (PrintBottomMargin != -1 && PrintTopMargin != -1 && PrintLeftMargin != -1 && PrintRightMargin != -1)
psd.Flags |= PSD_MARGINS ;
psd.hInstance = hInstance ;
psd.lpfnPageSetupHook = PageSetupHook ;
psd.lpPageSetupTemplateName = MAKEINTRESOURCE (IDD_PAGESETUP) ;
psd.rtMargin.bottom = PrintBottomMargin ;
psd.rtMargin.top = PrintTopMargin ;
psd.rtMargin.left = PrintLeftMargin ;
psd.rtMargin.right = PrintRightMargin ;
if (PageSetupDlg (&psd))
{
hPrinterDevMode = psd.hDevMode ;
hPrinterDevName = psd.hDevNames ;
PrintLeftMargin = psd.rtMargin.left ;
PrintTopMargin = psd.rtMargin.top ;
PrintRightMargin = psd.rtMargin.right ;
PrintBottomMargin = psd.rtMargin.bottom ;
PrintMarginUnitsMetric = (psd.Flags & PSD_INHUNDREDTHSOFMILLIMETERS) != 0 ;
}
}
void ScrollBarsClick (WPARAM wParam, LPARAM lParam)
{
int i ;
CCodeMax **e ;
CheckMenuRadioItem (LOWORD (wParam), CM_SCROLLFIRST, CM_SCROLLLAST) ;
EditConfig.ScrollBars = (TScrollStyle) (LOWORD (wParam) - CM_SCROLLFIRST) ;
for (i = 0, e = Editors ; i < EditorCount ; i++, e++)
{
(*e)->SetScrollBars (EditConfig.ScrollBars) ;
(*e)->EnableVSplitter (true) ;
(*e)->EnableHSplitter (true) ;
}
}
void SetTabSizeClick (WPARAM wParam, LPARAM lParam)
{
if (Editor != NULL)
{
int result = ShowEnterValueDialog ("Enter New Tab Size", 1, 16, Editor->GetTabSize ()) ;
if (result >= 1 && result <= 16)
Editor->SetTabSize (EditConfig.TabSize = result) ;
}
}
void OpenFileUnderCursorClick (WPARAM wParam, LPARAM lParam)
{
int count ;
CCodeMax *e ;
CStdString str ;
CStdStringList sl ;
if (Editor == NULL)
return ;
if (IncludeFilename == "")
{
SendMessage (hMainWindow, COPY_COMMANDLINE_MESSAGE, 0, (LPARAM) (LPCSTR) CommandLine) ;
return ;
}
str = IncludeFilename ;
// append dir if it isn't an absolute path
if (str [0] != '\\' && !(str.length () > 1 && isalpha (str [0]) && str [1] == ':'))
str = GetFilePath (Editor->m_Tag.LongName) + "\\" + IncludeFilename ;
if (FileExists (str))
{
if ((e = CreateNewEditor (str, false, true, false)) != NULL)
{
LocateRecentFile (str, e) ;
str.Format ("%s,%d,%d,%d,%d,%d,%d",
EncodeFilename(e->m_Tag.LongName).c_str(),
e->GetLineNo (),
e->GetColNo (),
e->GetTopLine (),
(int) e->GetLanguage (),
e->GetTabSize (),
(int) e->GetAutoIndent ()) ;
AddToRecent (str) ;
}
return ;
}
sl.LoadFromFile (POVRayIniPath) ;
str.Format ("Library_Path=%sinclude", DocumentsPath) ;
sl.AppendItem (str) ;
count = sl.ItemCount () ;
for (int i = 0 ; i < count ; i++)
{
str = sl [i].Trim () ;
if (str.Left (12).CompareNoCase ("Library_Path") == 0)
{
str = str.Mid (12).TrimLeft () ;
if (str [0] != '=')
continue ;
str.Delete (0) ;
str = FixPath (UnquotePath (str) + "\\" + IncludeFilename) ;
// append dir if it isn't an absolute path
if (str [0] != '\\' && !(str.length () > 1 && isalpha (str [0]) && str [1] == ':'))
str = GetFilePath (Editor->m_Tag.LongName) + "\\" + str ;
if (FileExists (str))
{
if ((e = CreateNewEditor (str, false, true, false)) != NULL)
{
LocateRecentFile (str, e) ;
str.Format ("%s,%d,%d,%d,%d,%d,%d",
EncodeFilename(e->m_Tag.LongName).c_str(),
e->GetLineNo (),
e->GetColNo (),
e->GetTopLine (),
(int) e->GetLanguage (),
e->GetTabSize (),
(int) e->GetAutoIndent ()) ;
AddToRecent (str) ;
}
return ;
}
}
}
PutStatusMessage ("Could not locate file") ;
}
void InsertMenuClick (int id)
{
CStdString str = InsertMenuItems [id] + ".txt" ;
CodemaxPos position ;
Editor->GetPosition (&position) ;
if (Editor->InsertFile (str, &position) != CODEMAX_SUCCESS)
ShowErrorMessage ("", "Failed to insert file") ;
}
void RecentFilesClick (int id)
{
CCodeMax *e ;
CStdString str ;
UpdateRecent () ;
if ((str = RecentFiles [id]) == "")
return ;
AddToRecent (str) ;
if (SelectFile (str))
return ;
if ((e = CreateNewEditor(DecodeFilename(GetNextField(str)), false, true, true)) != NULL)
{
e->SetLineNo (atoi (GetNextField (str))) ;
e->SetColNo (atoi (GetNextField (str))) ;
e->SetTopLine (atoi (GetNextField (str))) ;
e->SetLanguage ((TLanguage) atoi (GetNextField (str))) ;
e->SetTabSize (atoi (GetNextField (str))) ;
e->SetAutoIndent ((TAutoIndent) atoi (GetNextField (str))) ;
}
}
void OlderFilesClick (int id)
{
CCodeMax *e ;
CStdString str ;
UpdateRecent () ;
if ((str = OlderFiles [id]) == "")
return ;
AddToRecent (str) ;
if (SelectFile (str))
return ;
if ((e = CreateNewEditor (GetNextField (str), false, true, true)) != NULL)
{
e->SetLineNo (atoi (GetNextField (str))) ;
e->SetColNo (atoi (GetNextField (str))) ;
e->SetTopLine (atoi (GetNextField (str))) ;
e->SetLanguage ((TLanguage) atoi (GetNextField (str))) ;
e->SetTabSize (atoi (GetNextField (str))) ;
e->SetAutoIndent ((TAutoIndent) atoi (GetNextField (str))) ;
}
}
bool HandleCommand (WPARAM wParam, LPARAM lParam)
{
PutStatusMessage ("") ;
if (LOWORD (wParam) >= CM_FIRSTRECENTFILE && LOWORD (wParam) <= CM_LASTRECENTFILE)
{
RecentFilesClick (LOWORD (wParam) - CM_FIRSTRECENTFILE) ;
return (true) ;
}
if (LOWORD (wParam) >= CM_FIRSTOLDERFILE && LOWORD (wParam) <= CM_LASTOLDERFILE)
{
OlderFilesClick (LOWORD (wParam) - CM_FIRSTOLDERFILE) ;
return (true) ;
}
if (LOWORD (wParam) >= CM_FIRSTWINDOW && LOWORD (wParam) <= CM_LASTWINDOW)
{
int i = LOWORD(wParam) - CM_FIRSTWINDOW;
if (i > MAX_EDITORS) // NB > is correct, we don't want >= in this case
return (true);
if (WindowList[i] == NULL)
return (true);
if (WindowList[i] == MessageWinTitle)
{
TabCtrl_SetCurSel (hTabWindow, 0) ;
TabIndexChanged();
}
else
SelectFile (WindowList[i]) ;
return (true) ;
}
// handle those messages that can be handled even if Editor == NULL
switch (LOWORD (wParam))
{
case CM_SAVEALL:
SaveAllFiles (true) ;
return (true) ;
case CM_OPENFILE:
BrowseFile (true) ;
return (true) ;
case CM_NEWFILE:
LoadFile (NULL) ;
return (true) ;
case CM_CLOSEALLFILES:
CloseAll () ;
return (true) ;
case CM_CLOSEALLBUTTHIS:
CloseAll (Editor) ;
return (true) ;
case CM_SHIFTLEFT:
if (Editor != NULL && Editor->m_Index > 0)
ShiftTab(true, Editor->m_Index + 1);
return (true) ;
case CM_SHIFTRIGHT:
if (Editor != NULL && Editor->m_Index < EditorCount - 1)
ShiftTab(false, Editor->m_Index + 1);
return (true) ;
case CM_PAGESETUP:
PageSetupClick () ;
return (true) ;
case CM_EXIT:
SendMessage (hNotifyWindow, WM_COMMAND, NotifyBase + NotifyExitRequest, 0) ;
return (true) ;
case CM_FILEMENUHELP:
SendMessage (hMainWindow, KEYWORD_LOOKUP_MESSAGE, 0, (LPARAM) "File Menu") ;
return (true) ;
case CM_INSERTMENUHELP:
SendMessage (hMainWindow, KEYWORD_LOOKUP_MESSAGE, 0, (LPARAM) "Insert Menu") ;
return (true) ;
case CM_SEARCHMENUHELP:
SendMessage (hMainWindow, KEYWORD_LOOKUP_MESSAGE, 0, (LPARAM) "Search Menu") ;
return (true) ;
case CM_TEXTMENUHELP:
SendMessage (hMainWindow, KEYWORD_LOOKUP_MESSAGE, 0, (LPARAM) "Text Menu") ;
return (true) ;
case CM_EDITMENUHELP:
SendMessage (hMainWindow, KEYWORD_LOOKUP_MESSAGE, 0, (LPARAM) "Edit Menu") ;
return (true) ;
case CM_EDITORMENUHELP:
SendMessage (hMainWindow, KEYWORD_LOOKUP_MESSAGE, 0, (LPARAM) "Editor Menu") ;
return (true) ;
case CM_WINDOWMENUHELP:
SendMessage (hMainWindow, KEYWORD_LOOKUP_MESSAGE, 0, (LPARAM) "Window Menu") ;
return (true) ;
}
if (Editor == NULL)
return (false) ;
if (LOWORD (wParam) >= CM_FIRSTINSERTMENUITEM && LOWORD (wParam) <= CM_LASTINSERTMENUITEM)
{
InsertMenuClick (LOWORD (wParam) - CM_FIRSTINSERTMENUITEM) ;
return (true) ;
}
switch (LOWORD (wParam))
{
case CM_SHOWPARSEMESSAGES :
case CM_CURSORBEYONDEOL :
case CM_AUTOLOADERRORFILE :
ToggleMenuItem (LOWORD (wParam)) ;
return (true) ;
case CM_CUT:
Editor->Cut () ;
return (true) ;
case CM_COPY:
Editor->Copy () ;
return (true) ;
case CM_PASTE:
Editor->Paste () ;
return (true) ;
case CM_UNDO:
Editor->Undo () ;
return (true) ;
case CM_REDO:
Editor->Redo () ;
return (true) ;
case CM_TOGGLEBOOKMARK:
Editor->ExecuteCommand (CODEMAX_CMD_BOOKMARKTOGGLE, 0) ;
return (true) ;
case CM_FIRSTBOOKMARK:
Editor->ExecuteCommand (CODEMAX_CMD_BOOKMARKJUMPTOFIRST, 0) ;
return (true) ;
case CM_LASTBOOKMARK:
Editor->ExecuteCommand (CODEMAX_CMD_BOOKMARKJUMPTOLAST, 0) ;
return (true) ;
case CM_NEXTBOOKMARK:
Editor->ExecuteCommand (CODEMAX_CMD_BOOKMARKNEXT, 0) ;
return (true) ;
case CM_PREVIOUSBOOKMARK:
Editor->ExecuteCommand (CODEMAX_CMD_BOOKMARKPREV, 0) ;
return (true) ;
case CM_CLEARALLBOOKMARKS:
Editor->ExecuteCommand (CODEMAX_CMD_BOOKMARKCLEARALL, 0) ;
return (true) ;
case CM_SAVE:
SaveFile (NULL) ;
return (true) ;
case CM_SAVEAS:
SaveAsClick (wParam, lParam) ;
return (true) ;
case CM_CLOSEFILE:
case CM_CLOSECURRENTFILE:
CloseFile (NULL) ;
return (true) ;
case CM_PRINT:
PrintClick () ;
return (true) ;
case CM_FIND:
FindClick () ;
return (true) ;
case CM_REPLACE:
ReplaceClick () ;
return (true) ;
case CM_FINDNEXT:
Editor->FindNext () ;
return (true) ;
case CM_MATCHBRACE:
Editor->ExecuteCommand (CODEMAX_CMD_GOTOMATCHBRACE, 0) ;
return (true) ;
case CM_GOTOLINE:
Editor->GoToLine (-1) ;
return (true) ;
case CM_INDENTSELECTION:
Editor->ExecuteCommand (CODEMAX_CMD_INDENTSELECTION, 0) ;
return (true) ;
case CM_INDENTSELECTIONPREVIOUS:
Editor->ExecuteCommand (CODEMAX_CMD_INDENTTOPREV, 0) ;
return (true) ;
case CM_UNDENTSELECTION:
Editor->ExecuteCommand (CODEMAX_CMD_UNINDENTSELECTION, 0) ;
return (true) ;
case CM_UPPERCASESELECTION:
Editor->ExecuteCommand (CODEMAX_CMD_UPPERCASESELECTION, 0) ;
return (true) ;
case CM_LOWERCASESELECTION:
Editor->ExecuteCommand (CODEMAX_CMD_LOWERCASESELECTION, 0) ;
return (true) ;
case CM_SPACESTOTABS:
Editor->ExecuteCommand (CODEMAX_CMD_TABIFYSELECTION, 0) ;
return (true) ;
case CM_TABSTOSPACES:
Editor->ExecuteCommand (CODEMAX_CMD_UNTABIFYSELECTION, 0) ;
return (true) ;
case CM_OPENFILEUNDERCURSOR:
OpenFileUnderCursorClick (wParam, lParam) ;
return (true) ;
case CM_CONTEXTHELP:
GetContextHelp () ;
return (true) ;
case CM_SHOWMESSAGES:
MessagePaneVisible = !MessagePaneVisible ;
ShowMessagePane () ;
return (true) ;
case CM_PROPERTIES:
case CM_CUSTOMCOLOURS:
Editor->ShowProperties () ;
return (true) ;
case CM_OLDERFILES:
return (true) ;
case CM_DELETE:
Editor->ExecuteCommand (CODEMAX_CMD_DELETE, 0) ;
return (true) ;
case CM_SELECTALL:
Editor->ExecuteCommand (CODEMAX_CMD_SELECTALL, 0) ;
return (true) ;
case CM_SHOWWHITESPACE:
Editor->EnableWhitespaceDisplay (ToggleMenuItem (CM_SHOWWHITESPACE)) ;
return (true) ;
case CM_SETREPEATCOUNT:
Editor->ExecuteCommand (CODEMAX_CMD_SETREPEATCOUNT, 0) ;
return (true) ;
case CM_SETTABSIZE:
SetTabSizeClick (wParam, lParam) ;
return (true) ;
case CM_INDENTSTYLENONE:
case CM_INDENTSTYLELANGUAGE:
case CM_INDENTSTYLECOPY:
CheckMenuRadioItem (LOWORD (wParam), CM_INDENTSTYLEFIRST, CM_INDENTSTYLELAST) ;
EditConfig.AutoIndent = (TAutoIndent) (LOWORD (wParam) - CM_INDENTSTYLEFIRST) ;
Editor->SetAutoIndent (EditConfig.AutoIndent) ;
return (true) ;
case CM_AUTOSAVE:
AutoSaveClick (wParam, lParam) ;
return (true) ;
case CM_CREATEBACKUPS:
CreateBackups = ToggleMenuItem (CM_CREATEBACKUPS) ;
return (true) ;
case CM_UNDOAFTERSAVE:
UndoAfterSave = ToggleMenuItem (CM_UNDOAFTERSAVE) ;
return (true) ;
case CM_CONSTRAINCARET:
ConstrainCaretClick (wParam, lParam) ;
return (true) ;
case CM_OVERLAYKEYWORDEXPANSION:
EditConfig.TabKeywordExpansion = ToggleMenuItem (CM_OVERLAYKEYWORDEXPANSION) ;
return (true) ;
case CM_AUTORELOADNEVER:
case CM_AUTORELOADASK:
case CM_AUTORELOADALWAYS:
AutoReload = LOWORD (wParam) - CM_AUTORELOADFIRST ;
return (true) ;
case CM_SCROLLNONE:
case CM_SCROLLHORIZONTAL:
case CM_SCROLLVERTICAL:
case CM_SCROLLBOTH:
ScrollBarsClick (wParam, lParam) ;
return (true) ;
case CM_BLACKONWHITE:
memcpy (&EditConfig.Colours, &DefaultColours, sizeof (CodemaxColors)) ;
for (int i = 0 ; i < EditorCount ; i++)
Editors [i]->SetColors (&EditConfig.Colours) ;
return (true) ;
case CM_WHITEONBLACK:
memcpy (&EditConfig.Colours, &CJCColours, sizeof (CodemaxColors)) ;
for (int i = 0 ; i < EditorCount ; i++)
Editors [i]->SetColors (&EditConfig.Colours) ;
return (true) ;
case CM_RECORDMACRO:
Editor->ExecuteCommand (CODEMAX_CMD_RECORDMACRO, 0) ;
return (true) ;
case CM_PLAYMACRO1:
case CM_PLAYMACRO2:
case CM_PLAYMACRO3:
case CM_PLAYMACRO4:
case CM_PLAYMACRO5:
case CM_PLAYMACRO6:
case CM_PLAYMACRO7:
case CM_PLAYMACRO8:
case CM_PLAYMACRO9:
case CM_PLAYMACRO10:
Editor->ExecuteCommand ((WORD) (CODEMAX_CMD_PLAYMACRO1 + LOWORD (wParam) - CM_PLAYMACRO1), 0) ;
return (true) ;
case CM_EDITINSERTMENU:
ShellExecute (hMainWindow, "open", InsertPath, NULL, NULL, SW_SHOWNORMAL) ;
return (true) ;
case CM_SPLITHORIZONTALLY:
if (Editor->IsHSplitterEnabled() && Editor->GetHSplitterPos() == 0)
{
RECT rect;
GetClientRect (hTabWindow, &rect) ;
Editor->SetHSplitterPos(rect.right / 2);
}
return (true);
case CM_SPLITVERTICALLY:
if (Editor->IsVSplitterEnabled() && Editor->GetVSplitterPos() == 0)
{
RECT rect;
GetClientRect (hTabWindow, &rect) ;
Editor->SetVSplitterPos(rect.bottom / 2);
}
return (true);
}
return (false) ;
}
|