Hi Simon,

On 08/03/06 18:41 +0100, Simon Kagstrom said ...
> On Thu, 6 Mar 2008 16:39:53 +0530
> Y Giridhar Appaji Nag <[EMAIL PROTECTED]> wrote:
> 
> > I'll ask you if I need some help (On a basic first attempt, there were
> > patch rejects that I should be able to resolve easily). 
> 
> Thanks for looking into this! It's a feature I personally use a lot
> while working with subversion.

I tried using the patch and there were a couple of issues.

 - There were a bunch of patch rejects because the patch is based on 3.1
   and we are at 3.2 now and the code has changed (in particular some of
   the menuList_size kind of variables.  I resolved those.
 - The patch attached to the bug report doesn't have the changes that
   are required for the options dialog.  I picked up the patch from your
   page http://www.ipd.bth.se/ska/sim_home/xxdiff.html and integrated
   those changes.

The result is the attached patch (and it seems to work), can you please
take a look, test it (I also can give you a special build if necessary)
and give me a go ahead?  I will then update the upstream bug with this
new patch and include the patch in 3.2-7.

Cheers,

Giridhar

-- 
Y Giridhar Appaji Nag | http://www.appaji.net/
#! /bin/sh /usr/share/dpatch/dpatch-run
## 06_user_commands_menu.dpatch by Y Giridhar Appaji Nag <[EMAIL PROTECTED]>
##
## DP: Implements a implement menu with user defined commands.  Thanks
## DP: "Simon Kågström" <[EMAIL PROTECTED]>

@DPATCH@
diff -urNad xxdiff-3.2~/src/app.cpp xxdiff-3.2/src/app.cpp
--- xxdiff-3.2~/src/app.cpp     2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/app.cpp      2008-03-23 09:50:49.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       2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/app.h        2008-03-23 09:50:07.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   2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/optionsDialog.cpp    2008-03-23 09:50:07.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     2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/optionsDialog.h      2008-03-23 09:50:07.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        2008-03-23 09:49:58.000000000 
+0530
+++ xxdiff-3.2/src/optionsDialogBase.ui 2008-03-23 09:50:07.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       2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/resParser.cpp        2008-03-23 09:50:07.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 repectively. 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 2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/resParser.l  2008-03-23 09:50:07.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 2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/resParser.y  2008-03-23 09:50:07.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       2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/resources.cpp        2008-03-23 09:50:07.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 2008-03-23 09:49:58.000000000 +0530
+++ xxdiff-3.2/src/resources.h  2008-03-23 09:50:07.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  2008-03-23 09:50:07.000000000 +0530
+++ xxdiff-3.2/src/resources.inline.h   2008-03-23 09:50:07.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,

Attachment: signature.asc
Description: Digital signature

Reply via email to