[Eric] Some Template Suggestions

Larry Shaffer larrys at dakotacarto.com
Wed Jan 6 16:54:34 GMT 2010


Hi,

Attached is a diff for TemplateViewer.py which implements draft working
versions of:

$dir_project$
Renamed to $project_path$

$cur_select$

$insertion$

$select_start$ and $select_end$

The insertion and selection variables are just last minute token
replacements after all other variables are expanded. Don't think they should
be used together in the same template (doesn't make sense).

Couldn't figure out how to dump the editor's clipboard contents to a
variable, for $clipboard$. How's this done?



Fixed the insertion after template placement bug from the current code.

Patch code can do doubt be more efficiently written.

--
Larry


> From: Larry Shaffer <larrys at dakotacarto.com>
> Date: Tue, 05 Jan 2010 04:28:19 -0700
> To: "eric at riverbankcomputing.com" <eric at riverbankcomputing.com>
> Subject: [Eric] Some Template Suggestions
> 
> I like the template feature in eric4 (latest 4.4 snapshot on Mac OS X).
> Especially like the quick keyboard input. Here are some of my suggestions
> for additional predefined variables:
> 
> 
> $clipboard$
> Replaced with any current clipboard contents.
> 
> 
> $cur_select$
> Replaced with any current text selection. Would only work when
> double-clicking the template, which currently deletes any selection. Useful
> for wrapping existing code. Would have to accommodate any additional new
> indent level.
> 
> 
> $insertion$
> Sets insertion point for cursor after template is inserted. Usually defaults
> to end of template now, though there appears to be a bug in the current
> insertion placement calculation.
> 
> 
> $select_start$ and $select_end$
> Sets span of selected text in template after template is inserted. Good for
> making help text in template ready for overwriting.
> 
> 
> $py:/absolute/path/to/file.py$
> Replaced with executed Python script results, before template is inserted.
> Maybe also $py_project:project-root-relative/path/to/file.py$
> 
> 
> $dir_project$
> Inserts path to script's current project directory (if any). I believe
> $dir_name$ is script's parent directory, not project.
> 
> 
> I'll try to hack what I can into TemplateViewer.py and submit any diffs if
> successful. Adding clipboard, cur_select and dir_project looks
> straightforward.
> 
> Editing of template contents within a mini editor would be handy as well.
> 
> 
> -- 
> Larry
> 
> Mac OS X (10.5.8)
> Python 2.6.4 
> Qt 4.5.2 
> PyQt 4.5.4 
> sip 4.8.2 
> QScintilla 2.4 
> eric4 4.4-snapshot-20091129 (r3531)
> 
> 
> _______________________________________________
> Eric mailing list
> Eric at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/eric
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TemplateViewer.py.diff
Type: application/octet-stream
Size: 3823 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/eric/attachments/20100106/ac56df86/attachment.obj>


More information about the Eric mailing list