@ -1,5 +1,5 @@
//----------------------------------------------------------------------------
// Copyright (C) 2008 -2011 The IPython Development Team
// Copyright (C) 2008 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.
@ -9,11 +9,22 @@
// OutputArea
//============================================================================
/ * *
* @ module IPython
* @ namespace IPython
* @ submodule OutputArea
* /
var IPython = ( function ( IPython ) {
"use strict" ;
var utils = IPython . utils ;
/ * *
* @ class OutputArea
*
* @ constructor
* /
var OutputArea = function ( selector , prompt _area ) {
this . selector = selector ;
this . wrapper = $ ( selector ) ;
@ -59,8 +70,18 @@ var IPython = (function (IPython) {
this . collapse ( ) ;
} ;
/ * *
* Should the OutputArea scroll ?
* Returns whether the height ( in lines ) exceeds a threshold .
*
* @ private
* @ method _should _scroll
* @ param [ lines = 100 ] { Integer }
* @ return { Bool }
*
* /
OutputArea . prototype . _should _scroll = function ( lines ) {
if ( lines <= 0 ) { return }
if ( ! lines ) {
lines = 100 ;
}
@ -84,7 +105,7 @@ var IPython = (function (IPython) {
}
// maybe scroll output,
// if it's grown large enough and hasn't already been scrolled.
if ( ! that . scrolled && that . _should _scroll ( ) ) {
if ( ! that . scrolled && that . _should _scroll ( OutputArea . auto _scroll _threshold ) ) {
that . scroll _area ( ) ;
}
} ) ;
@ -143,9 +164,55 @@ var IPython = (function (IPython) {
this . scrolled = false ;
} ;
/ * *
* Threshold to trigger autoscroll when the OutputArea is resized ,
* typically when new outputs are added .
*
* Behavior is undefined if autoscroll is lower than minimum _scroll _threshold ,
* unless it is < 0 , in which case autoscroll will never be triggered
*
* @ property auto _scroll _threshold
* @ type Number
* @ default 100
*
* * /
OutputArea . auto _scroll _threshold = 100 ;
/ * *
* Lower limit ( in lines ) for OutputArea to be made scrollable . OutputAreas
* shorter than this are never scrolled .
*
* @ property minimum _scroll _threshold
* @ type Number
* @ default 20
*
* * /
OutputArea . minimum _scroll _threshold = 20 ;
/ * *
*
* Scroll OutputArea if height supperior than a threshold ( in lines ) .
*
* Threshold is a maximum number of lines . If unspecified , defaults to
* OutputArea . minimum _scroll _threshold .
*
* Negative threshold will prevent the OutputArea from ever scrolling .
*
* @ method scroll _if _long
*
* @ param [ lines = 20 ] { Number } Default to 20 if not set ,
* behavior undefined for value of ` 0 ` .
*
* * /
OutputArea . prototype . scroll _if _long = function ( lines ) {
if ( this . _should _scroll ( lines ) ) {
var n = lines | OutputArea . minimum _scroll _threshold ;
if ( n <= 0 ) {
return
}
if ( this . _should _scroll ( n ) ) {
// only allow scrolling long-enough output
this . scroll _area ( ) ;
}
@ -157,7 +224,7 @@ var IPython = (function (IPython) {
this . unscroll _area ( ) ;
} else {
// only allow scrolling long-enough output
this . scroll _if _long ( 20 ) ;
this . scroll _if _long ( ) ;
}
} ;
@ -466,7 +533,7 @@ var IPython = (function (IPython) {
toinsert . append ( latex ) ;
element . append ( toinsert ) ;
} ;
OutputArea . prototype . append _raw _input = function ( content ) {
var that = this ;
this . expand ( ) ;