Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek shellext: store context menu commands in an array

Changeset a3f4dec502da

Parent a3769970ee05

by David Golub

Changes to 2 files · Browse files at a3f4dec502da Showing diff from parent a3769970ee05 Diff from another changeset...

 
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
 
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
 
521
522
523
524
525
 
526
527
528
 
529
530
531
 
536
537
538
 
539
540
541
 
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
 
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
 
575
576
577
 
 
578
579
 
 
580
581
582
583
 
588
589
590
591
592
593
594
@@ -123,25 +123,73 @@
  // "iconfile.ico", 0 },  };   -static const char* const RepoNoFilesMenu = - "commit status shelve vdiff sep" - " add revert rename forget remove sep" - " workbench update grep sep kiln sep" - " synch serve clone init thgstatus sep" - " hgignore guess sep" - " shellconf repoconf userconf sep" - " about"; +static const LPCTSTR RepoNoFilesMenu[] = +{ + "commit", + "status", + "shelve", + "vdiff", + NULL, + "add", + "revert", + "rename", + "forget", + "remove", + NULL, + "workbench", + "update", + "grep", + NULL, + "kiln", + NULL, + "synch", + "serve", + "clone", + "init" + "thgstatus", + NULL, + "hgignore", + "guess", + NULL, + "shellconf", + "repoconf", + "userconf", + NULL, + "about", +};   -static const char* const RepoFilesMenu = - "commit status vdiff sep" - " add revert rename forget remove sep" - " log annotate sep kilnfiles sep" - " about"; +static const LPCTSTR RepoFilesMenu[] = +{ + "commit", + "status", + "vdiff", + NULL, + "add", + "revert", + "rename", + "forget", + "remove", + NULL, + "log", + "annotate", + NULL, + "kilnfiles", + NULL, + "about", +};   -static const char* const NoRepoMenu = - "clone init shellconf userconf thgstatus sep" - " workbench sep" - " about"; +static const LPCTSTR NoRepoMenu[] = +{ + "clone", + "init", + "shellconf", + "userconf", + "thgstatus", + NULL, + "workbench", + NULL, + "about", +};    static const LPCTSTR DefaultPromotedString = "commit,workbench,kiln,kilnfiles";   @@ -487,27 +535,33 @@
  bIsHgRepo, bFileMenu);     /* We have three menu types: files-selected, no-files-selected, no-repo */ - LPCTSTR lpszEntries = 0; + const LPCTSTR* ppszEntries = NULL; + int nCount;   if (bIsHgRepo)   {   if (bFileMenu) - lpszEntries = RepoFilesMenu; + { + ppszEntries = RepoFilesMenu; + nCount = sizeof(RepoFilesMenu) / sizeof(LPCTSTR); + }   else - lpszEntries = RepoNoFilesMenu; + { + ppszEntries = RepoNoFilesMenu; + nCount = sizeof(RepoNoFilesMenu) / sizeof(LPCTSTR); + }   }   else - lpszEntries = NoRepoMenu; + { + ppszEntries = NoRepoMenu; + nCount = sizeof(NoRepoMenu) / sizeof(LPCTSTR); + }     // start building TortoiseHg menus and submenus   ::InsertMenu(hMenu, indexMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);   - CAtlList<CString> listEntries; - Tokenize(lpszEntries, listEntries, " "); - - POSITION position = listEntries.GetHeadPosition(); - while (position != NULL) + for (int i = 0; i < nCount; i++)   { - CString strName = listEntries.GetNext(position); + CString strName = ppszEntries[i];   if (listPromoted.Find(strName) != NULL)   {   if ((strName == "kiln" || strName == "kilnfiles") && !KilnGetUrl(strCwd)) @@ -521,11 +575,9 @@
  {   UINT indexSubMenu = 0;   bool bIsSeparator = true; - POSITION position = listEntries.GetHeadPosition(); - while (position != NULL) + for (int i = 0; i < nCount; i++)   { - CString strName = listEntries.GetNext(position); - if (strName == "sep") + if (ppszEntries[i] == NULL)   {   if (!bIsSeparator)   { @@ -536,6 +588,7 @@
  }   else   { + CString strName = ppszEntries[i];   if (listPromoted.Find(strName) == NULL)   {   if ((strName == "kiln" || strName == "kilnfiles") && !KilnGetUrl(strCwd))
 
38
39
40
41
42
 
 
 
 
 
43
44
45
 
62
63
64
65
66
67
68
69
70
 
71
72
73
74
75
 
76
77
78
 
38
39
40
 
 
41
42
43
44
45
46
47
48
 
65
66
67
 
 
 
 
 
 
68
69
 
 
 
 
70
71
72
73
@@ -38,8 +38,11 @@
  // "iconfile.ico", 0 },  };   -static const char* const DropMenu = - "drag_move drag_copy"; +static const LPCTSTR DropMenu[] = +{ + "drag_move", + "drag_copy", +};    #define ResultFromShort(i) ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i)))   @@ -62,17 +65,9 @@
    InitMenuMaps(CDndMenuDescList, sizeof(CDndMenuDescList) / sizeof(CMenuDescription));   - LPCTSTR lpszEntries = DropMenu; - CAtlList<CString> listEntries; - Tokenize(lpszEntries, listEntries, " "); - - POSITION position = listEntries.GetHeadPosition(); - while (position != NULL) + for (int i = 0; i < sizeof(DropMenu) / sizeof(LPCTSTR); i++)   { - CString strName = listEntries.GetNext(position); - if (strName.IsEmpty()) - break; - InsertMenuItemByName(hMenu, strName, indexMenu++, idCmd++, idCmdFirst, L""); + InsertMenuItemByName(hMenu, DropMenu[i], indexMenu++, idCmd++, idCmdFirst, L"");   }     // separator