Difference between revisions of "Editor SlickEdit"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Custom Macro Commands Useful for Hackiing OO.o: added)
m (Custom Macro Commands Useful for Hackiing OO.o: typo)
Line 128: Line 128:
 
and the script copies all of *.vpw; *.vpj files to the new location while preserving their paths relative to the base directory.
 
and the script copies all of *.vpw; *.vpj files to the new location while preserving their paths relative to the base directory.
  
= Custom Macro Commands Useful for Hackiing OO.o =
+
= Custom Macro Commands Useful for Hacking OO.o =
 
+
  
 
= See Also =
 
= See Also =
 
* [http://developer.novell.com/wiki/index.php/Developer_Tool_Review_-_SlickEdit_10 Developer Tool Review - SlickEdit 10, Novell Developer Network]
 
* [http://developer.novell.com/wiki/index.php/Developer_Tool_Review_-_SlickEdit_10 Developer Tool Review - SlickEdit 10, Novell Developer Network]
 
[[Category:Developer Tools]]
 
[[Category:Developer Tools]]

Revision as of 21:01, 19 April 2007

Although not open-source nor free as in beer, SlickEdit is a powerful commercial code editor with a built-in symbol tagging and quick code navigation features just to name a few. It is especially well suited for a large-scale C/C++/Java project where the number of source files easily exceeds thousands. This page aims to describe how to set up SlickEdit for optimal hacking experience of OpenOffice.org (OO.o) codebase.

Editor Setup

Code format

Indentation

The OO.o project mandates 4-space indentation & use of whitespace characters for indentation for newly-submitted code. But the legacy code still mostly uses tab characters for indentation. So, you need to set up SlickEdit to properly handle this format.

Go to Tools > Options > File Extension Setup..., and select the extension of c. Select the Indent tab page and set the following options:

  • Change the Indent style to Syntax indent, and set the number to 4.
  • Set the Tabs setting to +4, which sets the tab spacing to every 4 characters.
  • Uncheck the Indent with tabs check box if checked.

The c extension also covers other file extensions that are commonly used for C/C++ sources files, such as cpp, cxx, h, hpp, and hxx, so you don't need to set these options for all of these extensions individually. We also use another extension hrc to manage string resource identifiers. So you should probably add this extension and have it refer to the c extension so that it is treated as a C/C++ extension (to get the syntax highlighting and symbol tagging to work correctly).

Brace style

Although there is no one particular brace style that our project mandates, we generally use BSD style throughout our code base. A BSD style code looks like this:

 if (condition)
 {
     // Do something for this condition....
 }
 else
 {
     // Do something different when the condition is not met...
 }

To set this brace style for the editor so that its various syntax expansion features can set the brace(s) in the right place, go to Tools > Options > File Extension Setup..., select the c extension, click the Options button in the bottom, and set the brace style to Style 2.

Workspace Setup

Setting up workspace and projects

SlickEdit's built-in symbol database is workspace-wide, so it's important to set up your workspace and projects with this in mind.

Copying workspace files

Because of the frequent resyncing of CWS, the workspace for an old milestone becomes obsolete after the resync. I've written a python script to copy the old workspace & project files into a new build tree. The source code for this script is posted below.

[python,N]

  1. !/usr/bin/env python
  2. copy_seworkspace.py

import sys, os.path, getopt, shutil

def debug(msg, abort=True):

   sys.stderr.write(msg+"\n")
   if abort:
       sys.exit(1)

def usage():

   # TODO: write a nice usage output here.
   pass

class SEWorkspace(object):

   @staticmethod
   def visit(instance, dirname, names):
       for name in names:
           if os.path.splitext(name)[1] in ['.vpw', '.vpj']:
               fullpath = dirname + "/" + name
               instance.addSrcWorkspaceFile(fullpath)


   def __init__(self, srcdir, destdir):
       if not os.path.isdir(srcdir):
           debug(srcdir + " is not a directory")
       if not os.path.isdir(destdir):
           debug(destdir + " is not a directory")
       self.srcdir = os.path.abspath(srcdir)
       self.destdir = os.path.abspath(destdir)
       self.filelist = []
       # Print some useful output.
       print "-"*68
       print "source dir: %s"%self.srcdir
       print "destination dir: %s"%self.destdir


   def walk(self):
       print "base directory is " + self.srcdir
       # Find all of vpw and vpj files under this path.
       os.path.walk(self.srcdir, SEWorkspace.visit, self)


   def addSrcWorkspaceFile(self, filepath):
       filepath = os.path.abspath(filepath)
       self.filelist.append(filepath)
       print "adding %s ..."%filepath


   def copyToDest(self):
       print "-"*68
       print "copying to destination directory ..."
       for srcfile in self.filelist:
           if srcfile.find(self.srcdir) != 0:
               continue
           destfile = srcfile.replace(self.srcdir, self.destdir)
           print "writing %s ..."%destfile
           shutil.copy(srcfile, destfile)
       return


def main(args):

   try:
       opts, args = getopt.getopt(args, "", [])
   except getopt.GetoptError:
       usage()
       sys.exit(1)
   if len(args) < 2:
       debug("takes two arguments")
   obj = SEWorkspace(args[0], args[1])
   obj.walk()
   obj.copyToDest()


if __name__=='__main__':

   main(sys.argv[1:])

To use, just run

 ./copy_seworkspace.py [old base dir] [new base dir]

and the script copies all of *.vpw; *.vpj files to the new location while preserving their paths relative to the base directory.

Custom Macro Commands Useful for Hacking OO.o

See Also

Personal tools