-->

Calltips/Docstring while viewing function list?

2019-02-18 13:50发布

问题:

I just recently switched to Komodo for Python programming, and I'm loving it so far. I love how if I type a function name, followed by the open-paren (, it opens the calltip/docstring. I also love how if I type a module name, followed by ., it opens a list of available functions. My question is, is it possible to get the calltip/docstring to popup when I have the function list up? In other words, I want to be able to see what each function does (the docstring) before I insert it and open the argument list with the (. The reason is that I find myself needing a function, and scrolling through the function list and inserting functions that look relevant to bring up the docstring to see if that's the exact one I want, and then if it's not, deleting it and trying again (by bringing back up the function list). This functionality is present in Eclipse, and I'm trying to mimic it.

Sorry if that was convoluted, and thanks in advance for any help.

回答1:

Use a macro which inserts the selected function, adds the parentheses, and triggers the calltip automatically. Both popups cannot be shown simultaneously, so assign the macro to a keyboard shortcut, and alternate between that shortcut and the undo shortcut to add/remove parentheses and show/hide the function list:

komodo.assertMacroVersion(2);
if (komodo.view && komodo.view.scintilla) { komodo.view.scintilla.focus(); }

var editor = ko.views.manager.currentView.scimoz;
var cursor_character = editor.getCharAt(editor.currentPos - 1); //get cursor position
editor.autoCComplete(); //autocomplete selected function in list
editor.copyText(1,"("); //add left parentheses to buffer

if(cursor_character > 96 && cursor_character < 123)
  {
  editor.paste(); //add left parentheses to editor after a function name 
  }
ko.commands.doCommand("cmd_triggerPrecedingCompletion"); //trigger calltip or function list

References

  • Scintilla Documentation: AutoCComplete
  • Komodo Command ID List