File: 06_user_commands_menu.patch

package info (click to toggle)
xxdiff 1%3A4.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,716 kB
  • ctags: 2,245
  • sloc: cpp: 18,495; python: 6,134; sh: 1,543; ansic: 1,535; perl: 308; lex: 284; yacc: 279; lisp: 250; tcl: 213; makefile: 82
file content (803 lines) | stat: -rwxr-xr-x 26,943 bytes parent folder | download | duplicates (7)
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
Description: Implements a menu with user defined commands.
 Patch thanks to Simon Kågström <simon.kagstrom@bth.se>
Reviewed-By: Y Giridhar Appaji Nag <giridhar@appaji.net>

diff -urNad xxdiff-3.2~/src/app.cpp xxdiff-3.2/src/app.cpp
--- xxdiff-3.2~/src/app.cpp	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/app.cpp	2009-04-29 18:44:24.000000000 +0530
@@ -1748,6 +1748,27 @@
 
    //---------------------------------------------------------------------------
 
+   // User menu
+   QkPopupMenu* userMenu = new QkPopupMenu;
+   for ( int ii = 0; ii < USER_COMMAND_LAST; ii++ ) {
+      if ( !_resources->getUserCommand(ii).isEmpty() ) {
+	 int id = userMenu->insertItem(
+	    _resources->getUserCommandTitle(ii), this, SLOT(userInvoke(int)),
+	    _resources->getAccelerator( ACCEL_USER_ADD_NEW )
+	 );
+	 userMenu->setItemParameter(id, ii);
+      }
+   }
+
+
+   //---------------------------------------------------------------------------
+
+   // User menu
+   _userMenu = new QkPopupMenu;
+   fillUserMenu();
+
+   //---------------------------------------------------------------------------
+
    // Help menu
    QkPopupMenu* helpMenu = new QkPopupMenu;
    helpMenu->insertItem(
@@ -1778,6 +1799,7 @@
    m->insertItem( "O&ptions", _optionsMenu );
    m->insertItem( "&Display", _displayMenu );
    m->insertItem( "W&indows", _windowsMenu );
+   m->insertItem( "&User", userMenu );
    m->insertSeparator();
    m->insertItem( "&Help", helpMenu );
 }
@@ -2963,6 +2985,44 @@
 
 //------------------------------------------------------------------------------
 //
+QString XxApp::getUserCommand(unsigned int id) const
+{
+   QString name;
+
+   // FIXME: Use _cmdline?
+   name = _resources->getUserCommand(id);
+
+   QString left, middle, right;
+   XxBuffer* leftbuf = getBuffer( 0 );
+   if ( leftbuf ) {
+      left = leftbuf->getName();
+   }
+   if ( _nbFiles == 2 ) {
+      XxBuffer* rightbuf = getBuffer( 1 );
+      if ( rightbuf ) {
+         right = rightbuf->getName();
+      }
+   }
+   else {
+      XxBuffer* middlebuf = getBuffer( 1 );
+      if ( middlebuf ) {
+         middle = middlebuf->getName();
+      }
+      XxBuffer* rightbuf = getBuffer( 2 );
+      if ( rightbuf ) {
+         right = rightbuf->getName();
+      }
+   }
+
+   name.replace( QRegExp("%L"), left );
+   name.replace( QRegExp("%M"), middle );
+   name.replace( QRegExp("%R"), right );
+
+   return name;
+}
+
+//------------------------------------------------------------------------------
+//
 void XxApp::saveSelectedOnly()
 {
    if ( _diffs.get() == 0 ) {
@@ -4183,6 +4243,23 @@
 
 //------------------------------------------------------------------------------
 //
+void XxApp::fillUserMenu()
+{
+   // Recreate the user menu
+   _userMenu->clear();
+   for ( int ii = 0; ii < USER_COMMAND_LAST; ii++ ) {
+      if ( !_resources->getUserCommand(ii).isEmpty() ) {
+	 int id = _userMenu->insertItem(
+	    _resources->getUserCommandTitle(ii), this, SLOT(userInvoke(int)),
+	    _resources->getAccelerator( ACCEL_USER_ADD_NEW )
+	 );
+	 _userMenu->setItemParameter(id, ii);
+      }
+   }
+}
+
+//------------------------------------------------------------------------------
+//
 void XxApp::synchronizeUI()
 {
    if ( _filesAreDirectories == false ) {
@@ -4606,4 +4683,32 @@
 
 }
 
+//------------------------------------------------------------------------------
+//
+void XxApp::userInvoke(int id)
+{
+   const char **args;
+   QStringList filenames;
+   QString command = getUserCommand(id);
+
+   XxUtil::splitArgs( command, filenames, args );
+   try {
+	XxUtil::spawnCommand( args );
+   }
+   catch ( const XxIoError& ioerr) {
+	QString text;
+	{
+	     QTextOStream oss( &text );
+	     oss << "There has been an error spawning user program:"
+		 << ioerr.getMsg() << endl;
+	}
+	QMessageBox* box = new XxSuicideMessageBox(
+	     _mainWindow, "Error.", text, QMessageBox::Warning
+	     );
+	box->show();
+
+   }
+   free (args);
+}
+
 XX_NAMESPACE_END
diff -urNad xxdiff-3.2~/src/app.h xxdiff-3.2/src/app.h
--- xxdiff-3.2~/src/app.h	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/app.h	2009-04-29 18:44:24.000000000 +0530
@@ -285,6 +285,7 @@
    void ignoreFileRight();
    void helpManPage();
    void helpAbout();
+   void fillUserMenu();
    // </group>
 
    // Keyboard accelerators cursor motion callbacks.
@@ -309,7 +310,11 @@
    void fontSizeIncrease();
    void fontSizeDecrease();
    // </group>
-   
+
+   // User-specified
+   // <group>
+   void userInvoke(int id);
+   // </group>
 signals:
 
    // Signal emitted when the cursor changes line.
@@ -404,6 +409,9 @@
    // Get the merged filename.
    QString getMergedFilename() const;
 
+   // Get a user command
+   QString getUserCommand(unsigned int id) const;
+
    // Compute if there is even a single byte different between the files.
    bool computeAbsoluteDifference() const;
 
@@ -456,6 +464,7 @@
    QkPopupMenu*            _displayMenu;
    QkPopupMenu*            _hordiffMenu;
    QkPopupMenu*            _windowsMenu;
+   QkPopupMenu*            _userMenu;
    int                     _menuids[ MAX_MENUIDS ];
    QWidget*                _overviewArea;
    QLabel*                 _remUnselView;
diff -urNad xxdiff-3.2~/src/optionsDialog.cpp xxdiff-3.2/src/optionsDialog.cpp
--- xxdiff-3.2~/src/optionsDialog.cpp	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/optionsDialog.cpp	2009-04-29 18:44:24.000000000 +0530
@@ -289,6 +289,16 @@
 
    // Make this dialog an observer of the resources.
    connect( resourcesPtr, SIGNAL( changed() ), this, SLOT( synchronize() ) );
+
+   //---------------------------------------------------------------------------
+   // User menu
+
+   connect( _comboUserCommand, SIGNAL( activated(int) ),
+            this, SLOT( userCommandSelected(int) ) );
+   connect( _editUserCommand, SIGNAL( textChanged(const QString &) ),
+            this, SLOT( userCommandTextChanged(const QString &) ) );
+   connect( _editUserCommandTitle, SIGNAL( textChanged(const QString &) ),
+            this, SLOT( userCommandTitleTextChanged(const QString &) ) );
 }
 
 //------------------------------------------------------------------------------
@@ -466,6 +476,13 @@
          _labelEditBack->update();
       }
    }
+
+   //---------------------------------------------------------------------------
+   // User menu
+
+   int n = _comboUserCommand->currentItem( );
+   _editUserCommandTitle->setText( resources.getUserCommandTitle( n ) );
+   _editUserCommand->setText( resources.getUserCommand( n ) );
 }
 
 //------------------------------------------------------------------------------
@@ -887,6 +904,37 @@
 
 //------------------------------------------------------------------------------
 //
+void XxOptionsDialog::userCommandSelected( int cmd )
+{
+   _comboUserCommand->setCurrentItem( cmd );
+   // Redraw the widgets
+   synchronize();
+}
+
+void XxOptionsDialog::userCommandTextChanged(const QString &newStr)
+{
+   XxResources& resources = _app->getResourcesNC();
+
+   resources.setUserCommand( (unsigned int) _comboUserCommand->currentItem(), newStr );
+   // Redraw the widgets
+   synchronize();
+   // Recreate the menu
+   _app->fillUserMenu();
+}
+
+void XxOptionsDialog::userCommandTitleTextChanged(const QString &newStr)
+{
+   XxResources& resources = _app->getResourcesNC();
+
+   resources.setUserCommandTitle( (unsigned int) _comboUserCommand->currentItem(), newStr );
+   // Redraw the widgets
+   synchronize();
+   // Recreate the menu
+   _app->fillUserMenu();
+}
+
+//------------------------------------------------------------------------------
+//
 bool XxOptionsDialog::isInCommand(
    const QString& command,
    const QString& option
diff -urNad xxdiff-3.2~/src/optionsDialog.h xxdiff-3.2/src/optionsDialog.h
--- xxdiff-3.2~/src/optionsDialog.h	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/optionsDialog.h	2009-04-29 18:44:24.000000000 +0530
@@ -170,6 +170,12 @@
    void editColorFore();
    void editColorBack();
 
+   //---------------------------------------------------------------------------
+   // User commands
+
+   void userCommandSelected( int cmd );
+   void userCommandTextChanged(const QString &newStr);
+   void userCommandTitleTextChanged(const QString &newStr);
 
 private:
 
diff -urNad xxdiff-3.2~/src/optionsDialogBase.ui xxdiff-3.2/src/optionsDialogBase.ui
--- xxdiff-3.2~/src/optionsDialogBase.ui	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/optionsDialogBase.ui	2009-04-29 18:44:24.000000000 +0530
@@ -1274,6 +1274,146 @@
                     </widget>
                 </vbox>
             </widget>
+            <widget class="QWidget">
+                <property name="name">
+                    <cstring>UserMenu</cstring>
+                </property>
+                <attribute name="title">
+                    <string>User menu</string>
+                </attribute>
+                <widget class="QLayoutWidget">
+                    <property name="name">
+                        <cstring>layout90</cstring>
+                    </property>
+                    <property name="geometry">
+                        <rect>
+                            <x>20</x>
+                            <y>10</y>
+                            <width>210</width>
+                            <height>50</height>
+                        </rect>
+                    </property>
+                    <hbox>
+                        <property name="name">
+                            <cstring>unnamed</cstring>
+                        </property>
+                        <widget class="QLabel">
+                            <property name="name">
+                                <cstring>textLabel3</cstring>
+                            </property>
+                            <property name="text">
+                                <string>Menu item</string>
+                            </property>
+                        </widget>
+                        <widget class="QComboBox">
+                            <item>
+                                <property name="text">
+                                    <string>Item 1</string>
+                                </property>
+                            </item>
+                            <item>
+                                <property name="text">
+                                    <string>Item 2</string>
+                                </property>
+                            </item>
+                            <item>
+                                <property name="text">
+                                    <string>Item 3</string>
+                                </property>
+                            </item>
+                            <property name="name">
+                                <cstring>_comboUserCommand</cstring>
+                            </property>
+                        </widget>
+                    </hbox>
+                </widget>
+                <widget class="QButtonGroup">
+                    <property name="name">
+                        <cstring>buttonGroup4_4_3</cstring>
+                    </property>
+                    <property name="geometry">
+                        <rect>
+                            <x>10</x>
+                            <y>60</y>
+                            <width>640</width>
+                            <height>120</height>
+                        </rect>
+                    </property>
+                    <property name="title">
+                        <string>User Command</string>
+                    </property>
+                    <widget class="QLabel">
+                        <property name="name">
+                            <cstring>TestLabel1_2_4</cstring>
+                        </property>
+                        <property name="geometry">
+                            <rect>
+                                <x>10</x>
+                                <y>70</y>
+                                <width>90</width>
+                                <height>29</height>
+                            </rect>
+                        </property>
+                        <property name="text">
+                            <string>Command:</string>
+                        </property>
+                    </widget>
+                    <widget class="QLabel">
+                        <property name="name">
+                            <cstring>TestLabel1_2_4_2</cstring>
+                        </property>
+                        <property name="geometry">
+                            <rect>
+                                <x>10</x>
+                                <y>30</y>
+                                <width>90</width>
+                                <height>29</height>
+                            </rect>
+                        </property>
+                        <property name="text">
+                            <string>Title:</string>
+                        </property>
+                    </widget>
+                    <widget class="QLineEdit">
+                        <property name="name">
+                            <cstring>_editUserCommandTitle</cstring>
+                        </property>
+                        <property name="geometry">
+                            <rect>
+                                <x>100</x>
+                                <y>30</y>
+                                <width>530</width>
+                                <height>29</height>
+                            </rect>
+                        </property>
+                        <property name="text">
+                            <string></string>
+                        </property>
+                        <property name="toolTip" stdset="0">
+                            <string>The title that appears for the User menu item</string>
+                        </property>
+                    </widget>
+                    <widget class="QLineEdit">
+                        <property name="name">
+                            <cstring>_editUserCommand</cstring>
+                        </property>
+                        <property name="geometry">
+                            <rect>
+                                <x>100</x>
+                                <y>70</y>
+                                <width>530</width>
+                                <height>29</height>
+                            </rect>
+                        </property>
+                        <property name="text">
+                            <string></string>
+                        </property>
+                        <property name="toolTip" stdset="0">
+                            <string>The command to execute when the menu item is selected</string>
+                        </property>
+                    </widget>
+                </widget>
+            </widget>
         </widget>
         <widget class="QLayoutWidget">
             <property name="name">
diff -urNad xxdiff-3.2~/src/resParser.cpp xxdiff-3.2/src/resParser.cpp
--- xxdiff-3.2~/src/resParser.cpp	2009-04-29 18:44:24.000000000 +0530
+++ xxdiff-3.2/src/resParser.cpp	2009-04-29 18:44:49.000000000 +0530
@@ -127,6 +127,13 @@
      "Color choice for diff hunks, and for certain other items in the text \
 view." },
 
+   { "User", USER,
+     "User-specified commands in the User menu. The command will be executed \
+when the entry is selected in the menu. %L, %M, %R can be used as placeholders \
+for left, middle and right filenames respectively. Note that ClearCase suffixes \
+are stripped automatically. Title specifies the title in the menu for the \
+command." },
+
    { "FontApp", FONT_APP,
      "General application font, used for widgets and menus." },
 
@@ -491,6 +498,15 @@
      " Color of text region selection " }
 };
 
+StringToken userList[] = {
+   { "UserCommand1", USER_COMMAND1,
+     "User command 1." },
+   { "UserCommand2", USER_COMMAND2,
+     "User command 2." },
+   { "UserCommand3", USER_COMMAND3,
+     "User command 3." },
+};
+
 StringToken commandList[] = {
    { "DiffFiles2", CMD_DIFF_FILES_2,
      "Command to use for comparing two files." },
@@ -590,7 +606,7 @@
 DECL_SIZE(commandSwitchList);
 DECL_SIZE(showList);
 DECL_SIZE(tagList);
-
+DECL_SIZE(userList);
 
 //------------------------------------------------------------------------------
 //
@@ -819,6 +835,7 @@
    sortTokens( commandSwitchList, commandSwitchList_size );
    sortTokens( showList, showList_size );
    sortTokens( tagList, tagList_size );
+   sortTokens( userList, userList_size );
 }
 
 //------------------------------------------------------------------------------
@@ -1069,6 +1086,20 @@
       }
    }
 
+   int nbuser = sizeof(userList)/sizeof(StringToken);
+   const char* userStr = searchTokenName( kwdList, kwdList_size, USER );
+   for ( ii = 0; ii < nbuser; ++ii ) {
+      XxUserCommand bo = XxUserCommand(userList[ii]._token);
+      const QString& bc1 = res1.getUserCommand( bo );
+      const QString& bt1 = res1.getUserCommandTitle( bo );
+      if ( bc1 != res2.getUserCommand( bo ) || bt1 != res2.getUserCommandTitle( bo )) {
+         os << userStr << "." << userList[ii]._name << ".Command" << ": \""
+            << bc1 << "\"" << endl;
+         os << userStr << "." << userList[ii]._name << ".Title" << ": \""
+            << bt1 << "\"" << endl;
+      }
+   }
+
    const char* initSwitchStr = searchTokenName( kwdList, kwdList_size, INITSW );
    for ( ii = 0; ii < nbcommandSwitch; ++ii ) {
       XxCommandSwitch bo = XxCommandSwitch(commandSwitchList[ii]._token);
@@ -1235,6 +1266,19 @@
          << b1.latin1() << "\"" << endl;
    }
 
+   int nbusercommand = sizeof(userList)/sizeof(StringToken);
+   const char* userCommandStr =
+      searchTokenName( kwdList, kwdList_size, USER );
+   for ( ii = 0; ii < nbusercommand; ++ii ) {
+      XxUserCommand bo = XxUserCommand(userList[ii]._token);
+      const QString& bc1 = res.getUserCommand( bo );
+      const QString& bt1 = res.getUserCommandTitle( bo );
+      os << userCommandStr << "." << userList[ii]._name << ".Command" << ": \""
+	 << bc1.latin1() << "\"" << endl;
+      os << userCommandStr << "." << userList[ii]._name << ".Title" << ": \""
+	 << bt1.latin1() << "\"" << endl;
+   }
+
    int nbcommandSwitch = sizeof(commandSwitchList)/sizeof(StringToken);
    const char* commandSwitchStr =
       searchTokenName( kwdList, kwdList_size, COMMANDSW );
@@ -1341,7 +1385,7 @@
       drbegin( os );
       int nbaccel = sizeof(accelList)/sizeof(StringToken);
       const StringToken* tok = searchToken( kwdList, kwdList_size, ACCEL );
-      os << tok->_name << "." << "[NAME]." << ": \"[ACCELERATOR]\"" << endl;
+      os << tok->_name << "." << "[NAME]" << ": \"[ACCELERATOR]\"" << endl;
       drend( os );
       ddbegin( os );
       os << tok->_desc << endl;
@@ -1458,6 +1502,49 @@
    }
 
    {
+      drbegin( os );
+      int nbusercommands = sizeof(userList)/sizeof(StringToken);
+      const StringToken* tok = searchToken( kwdList, kwdList_size, USER );
+      os << tok->_name << "." << "[NAME].[Command]"
+         << ": \"[COMMAND]\"" << endl;
+      os << tok->_name << "." << "[NAME].[Title]"
+         << ": \"[MENU TITLE]\"" << endl;
+      drend( os );
+      ddbegin( os );
+      os << tok->_desc << endl;
+
+      for ( ii = 0; ii < nbusercommands; ++ii ) {
+         const StringToken* tokc = &( userList[ii] );
+
+         drbegin( os );
+
+         os << tok->_name << "." << tokc->_name << ".Title" << ": \"";
+         if ( qApp != 0 ) {
+            os << res.getUserCommandTitle( ii );
+         }
+         else { 
+            os << "&lt;menu title&gt;";
+         }
+         os << "\"" << endl;
+
+         os << tok->_name << "." << tokc->_name << ".Command" << ": \"";
+         if ( qApp != 0 ) {
+            os << res.getUserCommand( ii );
+         }
+         else { 
+            os << "&lt;command&gt;";
+         }
+         os << "\"" << endl;
+
+         drend( os );
+         ddbegin( os );
+         os << tokc->_desc << endl;
+         ddend( os );
+      }
+      ddend( os );
+   }
+
+   {
       int nbbool = sizeof(boolkwdList)/sizeof(StringToken);
       for ( ii = 0; ii < nbbool; ++ii ) {
          XxBoolOpt bo = static_cast<XxBoolOpt>( boolkwdList[ii]._token - BOOLKWD_BASE );
diff -urNad xxdiff-3.2~/src/resParser.l xxdiff-3.2/src/resParser.l
--- xxdiff-3.2~/src/resParser.l	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/resParser.l	2009-04-29 18:44:24.000000000 +0530
@@ -49,6 +49,7 @@
 extern StringToken commandSwitchList[];
 extern StringToken showList[];
 extern StringToken tagList[];
+extern StringToken userList[];
 
 extern int kwdList_size;
 extern int boolkwdList_size;
@@ -58,7 +59,7 @@
 extern int commandSwitchList_size;
 extern int showList_size;
 extern int tagList_size;
-
+extern int userList_size;
 }
 using namespace XxResParserNS;
 
@@ -101,6 +102,7 @@
 
 %s GEOM_SC
 %s ACCEL_SC
+%s USER_SC USERCT_SC
 %s COLOR_SC COLORBF_SC
 %s COMMAND_SC
 %s COMMANDSW_SC
@@ -149,6 +151,24 @@
    );
 }
 
+<USER_SC>{id}	{ 
+   int token = parseFromKeywordList(
+      userList, userList_size,
+      USERNAME, "user",
+      yytext, yylval->num
+   );
+   if ( token != ERROR_TOKEN ) {
+      BEGIN(USERCT_SC);
+   }
+   return token;
+}
+
+<USERCT_SC>([cC]ommand|[tT]itle)	{ 
+   BEGIN(INITIAL);
+   yylval->num = ( (yytext[0] == 'c') || (yytext[0] == 'C') ) ? USERCOMMAND : USERTITLE;
+   return yylval->num;
+}
+
 <COLOR_SC>{id}	{
    BEGIN(INITIAL);
    int token = parseFromKeywordList(
@@ -257,6 +277,7 @@
    switch ( yylval->num ) {
       case PREFGEOMETRY: BEGIN(GEOM_SC); break;
       case ACCEL: BEGIN(ACCEL_SC); break;
+      case USER: BEGIN(USER_SC); break;
       case COLOR: BEGIN(COLOR_SC); break;
       case COMMAND: BEGIN(COMMAND_SC); break;
       case COMMANDSW: BEGIN(COMMANDSW_SC); break;
diff -urNad xxdiff-3.2~/src/resParser.y xxdiff-3.2/src/resParser.y
--- xxdiff-3.2~/src/resParser.y	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/resParser.y	2009-04-29 18:44:24.000000000 +0530
@@ -77,6 +77,9 @@
 %token       ACCEL
 %token <num>   ACCELNAME
 
+%token       USER
+%token <num>   USERNAME USERCOMMAND USERTITLE
+
 %token       COLOR
 %token <num>   COLORNAME BACK FORE
 
@@ -141,6 +144,7 @@
 
 /* typed rules */
 %type <num> colorbf
+%type <num> userct
 %type <num> boolkwd
 
 %start xxdiffrc
@@ -158,6 +162,7 @@
 		| prefgeometry
 		| style
 		| accel
+                | user
 		| color
 		| boolopt
 		| command
@@ -235,6 +240,28 @@
                 }
 		;
 
+user		: USER DOT USERNAME DOT userct COLON STRING
+		{
+		   /*printf( "==> User %d, %d: %s\n", $3, $5, $7 );*/
+		   if ($5 == USERCOMMAND)
+		      RESOURCES->setUserCommand( $3, $7 );
+		   else if ($5 == USERTITLE)
+		      RESOURCES->setUserCommandTitle( $3, $7 );
+		   else {
+                      char buf[2048];
+                      ::snprintf( buf, 2048,
+                                  "Unrecognized user command: %s\n", $7 );
+                      yyerror( buf );
+                   }
+
+                }
+		;
+
+userct          : USERCOMMAND
+		| USERTITLE
+		;
+
+
 color		: COLOR DOT COLORNAME COLON STRING
 		{
                    /*printf( "==> color %d back: %s\n", $3, $5 );*/
diff -urNad xxdiff-3.2~/src/resources.cpp xxdiff-3.2/src/resources.cpp
--- xxdiff-3.2~/src/resources.cpp	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/resources.cpp	2009-04-29 18:44:24.000000000 +0530
@@ -802,6 +802,28 @@
 
 //------------------------------------------------------------------------------
 //
+void XxResources::setUserCommand( unsigned int n, const QString& fn )
+{
+   if (n < USER_COMMAND_LAST) {
+      _userCommand[n] = fn;
+      emit changed();
+   }
+   /* Fail silently */
+}
+
+//------------------------------------------------------------------------------
+//
+void XxResources::setUserCommandTitle( unsigned int n, const QString& fn )
+{
+   if (n < USER_COMMAND_LAST) {
+      _userCommandTitle[n] = fn;
+      emit changed();
+   }
+   /* Fail silently */
+}
+
+//------------------------------------------------------------------------------
+//
 bool XxResources::compareFonts( const QFont& f1, const QFont& f2 )
 {
    if ( f1.rawMode() || f2.rawMode() ) {
diff -urNad xxdiff-3.2~/src/resources.h xxdiff-3.2/src/resources.h
--- xxdiff-3.2~/src/resources.h	2009-04-29 18:34:35.000000000 +0530
+++ xxdiff-3.2/src/resources.h	2009-04-29 18:44:24.000000000 +0530
@@ -203,6 +203,7 @@
    ACCEL_IGNORE_FILE_LEFT,
    ACCEL_IGNORE_FILE_MIDDLE,
    ACCEL_IGNORE_FILE_RIGHT,
+   ACCEL_USER_ADD_NEW,
    ACCEL_HELP_MAN_PAGE,
    ACCEL_HELP_ON_CONTEXT,
    ACCEL_HELP_ABOUT,
@@ -337,6 +338,13 @@
    HD_MULTIPLE
 };
 
+enum XxUserCommand {
+   USER_COMMAND1,
+   USER_COMMAND2,
+   USER_COMMAND3,
+   USER_COMMAND_LAST, // Not a real resource
+};
+
 /*==============================================================================
  * CLASS XxResources
  *============================================================================*/
@@ -550,6 +558,14 @@
    void setMergedFilename( const QString& fn );
    // </group>
 
+   // Get/set user command.
+   // <group>
+   const QString& getUserCommand( unsigned int n) const;
+   void setUserCommand( unsigned n, const QString& fn );
+   const QString& getUserCommandTitle( unsigned int n) const;
+   void setUserCommandTitle( unsigned int n, const QString& fn );
+   // </group>
+
 
    // Return a table for the dynamic programming algorithm, if the maximum size
    // of the table allows it.  If not, then return 0.
@@ -627,6 +643,8 @@
    uint         _hordiffContext;
    uint         _showPaneMergedViewPercent;
    QString      _mergedFilename;
+   QString      _userCommand[ USER_COMMAND_LAST ];
+   QString      _userCommandTitle[ USER_COMMAND_LAST ];
 
    // Dynamic programming table used for horizontal diffs computation.
    // <group>
diff -urNad xxdiff-3.2~/src/resources.inline.h xxdiff-3.2/src/resources.inline.h
--- xxdiff-3.2~/src/resources.inline.h	2009-04-29 18:44:24.000000000 +0530
+++ xxdiff-3.2/src/resources.inline.h	2009-04-29 18:44:24.000000000 +0530
@@ -242,6 +242,24 @@
 
 //------------------------------------------------------------------------------
 //
+inline const QString& XxResources::getUserCommand(unsigned int n) const
+{
+   if (n < USER_COMMAND_LAST)
+      return _userCommand[n];
+   return _userCommand[USER_COMMAND_LAST-1];
+}
+
+//------------------------------------------------------------------------------
+//
+inline const QString& XxResources::getUserCommandTitle(unsigned int n) const
+{
+   if (n < USER_COMMAND_LAST)
+      return _userCommandTitle[n];
+   return _userCommandTitle[USER_COMMAND_LAST-1];
+}
+
+//------------------------------------------------------------------------------
+//
 inline void XxResources::setFbColors(
    XxColor     color,
    const char* backstr,