improve output limiting behavior, fixing #4179

Uses a dynamic variable to control output limiting, so that everything
inside interactive display is limited, but everything inside string(),
repr(), and showall() is not limited.