Exemple #1
0
  """Perform cvs update on the given files or directories"""
  __apply_cvs_op(filenames, 'update', cb=__message_completion)
   
def _cvs_update_available(filenames=wingapi.kArgFilename):
  if filenames is None or len(filenames) == 0:
    return False
  for filename in filenames:
    if not wingapi.IsUrl(filename):
      dir, version, date, flags = __read_entries_file(filename)
      if version is not None:
        return True
  return False
cvs_update.available = _cvs_update_available
cvs_update.label = _('CVS _Update')

cvs_update.contexts = [wingapi.kContextEditor(), 
                       wingapi.kContextProject(),
                       wingapi.kContextNewMenu(_("_CVS"), 1)]

def cvs_diff(filenames=wingapi.kArgFilename):
  """Perform cvs diff on the given files or directories.  The form of diff
  is controlled from the options dialog."""
  app = wingapi.gApplication
  diff_type = app.fSingletons.fFileAttribMgr[_kDiffTypeAttrib]
  if diff_type == 'default':
    cvs_ndiff(filenames)
  elif diff_type == 'context':
    cvs_cdiff(filenames)
  else:
    cvs_udiff(filenames)
   
Exemple #2
0

def find_clicked_uses_and_search():
    app = wingapi.gApplication
    ed = app.GetActiveEditor()
    try:
        pos = ed.GetClickLocation()
    except:
        pos = ed.fEditor._FindPoint()[1]
    ed.SetSelection(pos, pos)
    app.ExecuteCommand('select-current-word')
    app.ExecuteCommand('find-points-of-use')
    app.ExecuteCommand('batch-search')


find_clicked_uses_and_search.contexts = (wingapi.kContextEditor(), )
find_clicked_uses_and_search.label = "Find Uses and Search"


def rename_clicked_and_search():
    app = wingapi.gApplication
    ed = app.GetActiveEditor()
    try:
        pos = ed.GetClickLocation()
    except:
        pos = ed.fEditor._FindPoint()[1]
    ed.SetSelection(pos, pos)
    app.ExecuteCommand('select-current-word')
    app.ExecuteCommand('rename-symbol')
    app.ExecuteCommand('batch-search')
Exemple #3
0
import subprocess
import tempfile
import wingapi
import thread

_ = gettext.translation('scripts_editor_extensions', fallback=1).ugettext


def gnome_open(filenames=wingapi.kArgFilename):
    """Perform svn diff on the given files or directories."""
    app = wingapi.gApplication
    subprocess.Popen(['gnome-open'] + filenames)


gnome_open.label = _('_Gnome Open')
gnome_open.contexts = [wingapi.kContextEditor(), wingapi.kContextProject()]


def _nautilus_browse_available(filenames=wingapi.kArgFilename):
    for f in filenames:
        if os.path.isdir(f):
            return True


def nautilus_browse(filenames=wingapi.kArgFilename):
    """Perform svn diff on the given files or directories."""
    for f in filenames:
        if os.path.isdir(f):
            subprocess.Popen(['nautilus'] + [f])

Exemple #4
0
  """Perform svn update on the given files or directories"""
  __apply_svn_op(filenames, 'update', cb=__message_completion)
  
def _svn_update_available(filenames=wingapi.kArgFilename):
  if filenames is None or len(filenames) == 0:
    return False
  for filename in filenames:
    if not wingapi.IsUrl(filename):
      version, date, kind, author, url, exists = __read_entries_file(filename)
      if version is not None or kind == 'dir':
        return True
  return False
svn_update.available = _svn_update_available
svn_update.label = _('SVN _Update')

svn_update.contexts = [wingapi.kContextEditor(), 
                       wingapi.kContextProject(),
                       wingapi.kContextNewMenu(_("S_VN"), 1)]

def svn_revert(filenames=wingapi.kArgFilename):
  """Perform svn revert on the given files or directories"""
  def doit():
    __apply_svn_op(filenames, 'revert', cb=__message_completion)
  title = _("Discard Changes in Files?")
  msg = _("Are you sure you want to discard your changes to all the "
          "selected files and revert to the current state on this "
          "branch in Subversion?")
  buttons = [
    dialogs.CButtonSpec(_("OK"), doit),
    dialogs.CButtonSpec(_("Cancel"), None),
  ]
Exemple #5
0
    start, end = editor.GetSelection()
    _open_filename_at_position(editor, start)


def open_clicked_filename():
    '''Open the clicked file name.  Relative paths are resolved using the
    location of the editor's file.'''
    editor = wingapi.gApplication.GetActiveEditor()
    try:
        pos = editor.GetClickLocation()
    except:
        pos = editor.fEditor._FindPoint()[1]
    _open_filename_at_position(editor, pos)


open_clicked_filename.contexts = (wingapi.kContextEditor(), )
open_clicked_filename.label = "Open Clicked Filename"

_kNonFilenameChars = ' \t\n\r()*,;\'"'


def _open_filename_at_position(editor, start):

    document = editor.GetDocument()
    startpos, endpos = None, None
    offset = 0
    doclen = document.GetLength()
    while startpos is None or endpos is None:
        if start - offset > 0 and startpos is None:
            c1 = document.GetCharRange(start - offset - 1, start - offset)
            if c1 in _kNonFilenameChars:
Exemple #6
0
                                      datatype.CType(''), 
                                      formbuilder.CFileSelectorGui(name_type=dialogs.kExistingDirectoryName),
                                      label=_("_Update"))

# Determines when the command is available for invocation. If omitted,
# the command is always available.  May also be set to a constant value.
def _cvs_update_available(filename=wingapi.kArgFilename):
  return filename is not None
cvs_update.available = _cvs_update_available
cvs_update.label = 'Update'

# Flags that affect how this command is made available in Wing's user
# interface.  When omitted, the command is only available by name from the
# master command list and the keyboard navigator (which includes all
# commands by default)
cvs_update.contexts = [wingapi.kContextEditor(), 
                       wingapi.kContextProject(),
                       wingapi.kContextNewMenu(_("_CVS"))]

#-----------------------------------------------------------------------

def test(filename, comment=_("None")):
  print _("Testing!")
  print _("Filename"), filename
  print _("Comment"), comment

  buttons = (dialogs.CButtonSpec(_('OK'), None),)
  dlg = messages.CMessageDialog(wingapi.gApplication.fSingletons, _("Test result"), 
                               _("File %s: %s") % (filename, comment), [], buttons)

# Note that arginfo can also be a callable that returns the arg info