--- moop/lib/moop.py Sat Mar 27 21:26:42 2004 +++ moop-local/lib/moop.py Sun Sep 12 17:28:13 2004 @@ -1241,6 +1241,7 @@ '_editProp': '', # name of property we're editing '_editBuf': [], # edit buffer '_editState': None, # edit state (temp storage) + '_editAddr': 0, # edit address line '_prompt': '>', # user prompt '_oldprompt': '', # previous prompt '__isuser': 1 } # yes, we're a user @@ -1400,18 +1401,22 @@ self.__dict__['_editObj'] = prop self.__dict__['_editProp'] = "source" copyList(prop.source, self._editBuf) + self.__dict__['_editAddr'] = len(self._editBuf) elif type(prop) == ListType or type(prop) == TupleType: self.__dict__['_editObj'] = object self.__dict__['_editProp'] = propname copyList(prop, self._editBuf) + self.__dict__['_editAddr'] = len(self._editBuf) + elif type(prop) == StringType: + self.__dict__['_editObj'] = object + self.__dict__['_editProp'] = propname + self.__dict__['_editBuf'] = string.split(prop, '\n') + self.__dict__['_editAddr'] = len(self._editBuf) else: try: raise "TypeError", "Can't edit "+ str(type(prop.val)) +" objects" except AttributeError: - if type(prop) == StringType: - raise "TypeError", "Can't use editor on simple strings, try setting the property instead." - else: - raise "TypeError", "Can't edit %s: unknown prop type" % prop + raise "TypeError", "Can't edit %s: unknown prop type" % prop self.__dict__['_postEditFunc'] = postEdit # set editor prompt @@ -1468,16 +1473,25 @@ if not self._editObj: raise "Error", "endEdit() called while not editing!" if save: - setattr( self._editObj, self._editProp, tuple(self._editBuf) ) - if self._postEditFunc: - try: - self._postEditFunc( self, self._editObj, self._editProp, save ) - except: - self.tell( "Error calling post-edit function " \ - + str(self._postEditFunc) ) + prop = getattr(self._editObj, self._editProp) + if type(prop) == StringType: + if type(self._editBuf) == StringType: + setattr(self._editObj, self._editProp, self._editBuf) + else: + setattr(self._editObj, self._editProp, + string.join(self._editBuf, '\n')) + else: + setattr(self._editObj, self._editProp, tuple(self._editBuf)) + # Needs to be this way so that _postEditFunc can reset + # _editObj if it wants to. - DA + editObj = self._editObj + editProp = self._editProp + postEdit = self._postEditFunc + self.__dict__['_editObj'] = None self.__dict__['_editProp'] = '' self.__dict__['_editBuf'] = [] + self.__dict__['_editAddr'] = 0 self.__dict__['_postEditFunc'] = None #------------------------------------------------------------------