@ -1,9 +1,6 @@
//----------------------------------------------------------------------------
// Copyright (C) 2008-2011 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
//============================================================================
// Tooltip
//============================================================================
@ -105,8 +102,8 @@ var IPython = (function (IPython) {
this . tooltip . append ( this . text ) ;
// function that will be called if you press tab 1, 2, 3... times in a row
this . tabs _functions = [ function ( cell , text ) {
that . _request _tooltip ( cell , text );
this . tabs _functions = [ function ( cell , text , cursor ) {
that . _request _tooltip ( cell , text , cursor );
} , function ( ) {
that . expand ( ) ;
} , function ( ) {
@ -131,13 +128,10 @@ var IPython = (function (IPython) {
Tooltip . prototype . showInPager = function ( cell ) {
// reexecute last call in pager by appending ? to show back in pager
var that = this ;
var callbacks = { 'shell' : {
'payload' : {
'page' : $ . proxy ( cell . _open _with _pager , cell )
}
}
} ;
cell . kernel . execute ( that . name + '?' , callbacks , { 'silent' : false , 'store_history' : true } ) ;
var payload = { } ;
payload . text = that . _reply . content . data [ 'text/plain' ] ;
$ ( [ IPython . events ] ) . trigger ( 'open_with_text.Pager' , payload ) ;
this . remove _and _cancel _tooltip ( ) ;
} ;
@ -222,10 +216,9 @@ var IPython = (function (IPython) {
return Tooltip . last _token _re . exec ( line ) ;
} ;
Tooltip . prototype . _request _tooltip = function ( cell , line ) {
Tooltip . prototype . _request _tooltip = function ( cell , text, cursor _pos ) {
var callbacks = $ . proxy ( this . _show , this ) ;
var oir _token = this . extract _oir _token ( line ) ;
var msg _id = cell . kernel . object _info ( oir _token , callbacks ) ;
var msg _id = cell . kernel . object _info ( text , cursor _pos , callbacks ) ;
} ;
// make an imediate completion request
@ -236,10 +229,8 @@ var IPython = (function (IPython) {
this . cancel _pending ( ) ;
var editor = cell . code _mirror ;
var cursor = editor . getCursor ( ) ;
var text = editor . getRange ( {
line : cursor . line ,
ch : 0
} , cursor ) . trim ( ) ;
var cursor _pos = IPython . utils . absolute _cursor _pos ( editor , cursor ) ;
var text = cell . get _text ( ) ;
this . _hide _if _no _docstring = hide _if _no _docstring ;
@ -260,17 +251,17 @@ var IPython = (function (IPython) {
this . reset _tabs _function ( cell , text ) ;
}
// don't do anything if line beg g in with '(' or is empty
if ( text === "" || text === "(" ) {
return ;
}
// don't do anything if line beg ins with '(' or is empty
// if (text === "" || text === "(") {
// return;
// }
this . tabs _functions [ this . _consecutive _counter ] ( cell , text );
this . tabs _functions [ this . _consecutive _counter ] ( cell , text , cursor _pos );
// then if we are at the end of list function, reset
if ( this . _consecutive _counter == this . tabs _functions . length ) {
this . reset _tabs _function ( cell , text );
}
this . reset _tabs _function ( cell , text , cursor );
}
return ;
} ;
@ -302,6 +293,7 @@ var IPython = (function (IPython) {
Tooltip . prototype . _show = function ( reply ) {
// move the bubble if it is not hidden
// otherwise fade it
this . _reply = reply ;
var content = reply . content ;
if ( ! content . found ) {
// object not found, nothing to show
@ -338,43 +330,14 @@ var IPython = (function (IPython) {
this . arrow . animate ( {
'left' : posarrowleft + 'px'
} ) ;
// build docstring
var defstring = content . call _def ;
if ( ! defstring ) {
defstring = content . init _definition ;
}
if ( ! defstring ) {
defstring = content . definition ;
}
var docstring = content . call _docstring ;
if ( ! docstring ) {
docstring = content . init _docstring ;
}
if ( ! docstring ) {
docstring = content . docstring ;
}
if ( ! docstring ) {
// For reals this time, no docstring
if ( this . _hide _if _no _docstring ) {
return ;
} else {
docstring = "<empty docstring>" ;
}
}
this . _hidden = false ;
this . tooltip . fadeIn ( 'fast' ) ;
this . text . children ( ) . remove ( ) ;
// This should support rich data types, but only text/plain for now
// Any HTML within the docstring is escaped by the fixConsole() method.
var pre = $ ( '<pre/>' ) . html ( utils . fixConsole ( docstring ) ) ;
if ( defstring ) {
var defstring _html = $ ( '<pre/>' ) . html ( utils . fixConsole ( defstring ) ) ;
this . text . append ( defstring _html ) ;
}
var pre = $ ( '<pre/>' ) . html ( utils . fixConsole ( content . data [ 'text/plain' ] ) ) ;
this . text . append ( pre ) ;
// keep scroll top to be sure to always see the first line
this . text . scrollTop ( 0 ) ;