Re: [Boa Constr] Tab-key in PySourceView
Status: Beta
Brought to you by:
riaan
From: Riaan B. <riaan@e.co.za> - 2001-04-07 19:57:09
|
Hi Mike, this is a quick note just to let you know I am here but still busy with the replies to your (and others') previous messages. I've addressed some of your issues and fixed bugs that have been reported since the release and hope to post the replies (and CVS) tonight. I've added tab, shift-tab/indent, dedent support. "Mike C. Fletcher" wrote: > > Hi all, looking at the tab-key handler in PySourceView (line 984), it could > use some enhancements. These are patterned after the PythonWin interactions > (IDLE too if I recall), and make the indent/dedent operations with the tab Idle uses Ctrl-] and Ctrl-[ (Which can't be bound to an accelerator table) > key much more natural feeling. > > My attempts to integrate the changes have failed. I can't seem to get the > PySourceView to actually use my modified function (so I haven't actually > tested it to see if it works). Although the OnKeyDown method appears like > the correct customisation point, it doesn't actually seem to get called. Did you also binf it in PrefsKeys.py ? I've explained this in my other message, in short; If a key is bound to an accelerator table, it does not generate further events for the control. > > tab -- should be translated to an indent command if within the leading > whitespace of the line and there's no selection > shift-tab -- should be translated to a dedent command if within the leading > whitespace of the line and there's no selection > if there is a multi-line selection, then both indent and dedent (tab and > shift-tab) should operate on the selection. > > Are there a lot of these 2600 line files around? > Mike Be fair, it's a 1280 line file (50k), and there 7 source files in the distribution bigger than 45k. My usual rule of thumb is to not let a file get longer than 1000 lines, although there are a few. > > 8<___________ PySourceView line 984 + > # Tabbed indent > elif key == 9: > print 'tab key' > # revised tab semantics mcfletch 2001 > if event.ShiftDown(): > print 'shift down' > # is a dedent request > self.OnDedent(event) > else: > # is likely an indent request > # will consider it an ident request if we're actually > # in the indentation section or we have a non-null selection > # set... > # selection set? > start, stop = self.GetSelection() > pos = self.GetCurrentPos() > startPosition = > self.GetLineStartPos(self.GetLineFromPos(pos)) > line = self.GetLineFromPos(pos) > prefix = string.strip(line[:(pos-startPosition)]) > def updatePosition( self, position ): > if old_stc: > self.SetCurrentPosition(position) > else: > self.SetSelectionStart(pos + indentLevel) > if (start == stop): > # is a tab-key in the indentation section, > # update the indentation to be one level deeper... > if prefix: > # there is a non-whitespace character in front of > position, > # insert an actual tab character > self.InsertText(pos, '\t') > updatePosition( self, pos + 1 ) > else: > # do an indent by inserting some whitespace > self.InsertText(pos, indentLevel*' ') > updatePosition( self, pos + indentLevel ) > else: > # non-null selection set... > self.OnIndent(event) > if not self.AutoCompActive(): return > > __________________________________ > Mike C. Fletcher > Designer, VR Plumber > http://members.home.com/mcfletch > > _______________________________________________ > Boa-constructor-users mailing list > Boa...@li... > http://lists.sourceforge.net/lists/listinfo/boa-constructor-users -- Riaan Booysen ___________________________________________________ Boa Constructor - RAD GUI building IDE for wxPython http://boa-constructor.sourceforge.net |