What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

Is there a way for a reader (not the OP) to expand a scrollable window containing source code in a question? I sometimes have difficulty understanding a block of code because I can't see it all at once. I find myself having to continually scroll the code up and down within the window. It would be nice to be able to request that the code in all of its entirety be displayed in the question.

share|improve this question
1  
Yeah! And add a split pane while you are at it, just like Visual Studio does. –  Oded Oct 28 '12 at 20:28
1  
@Oded - StackIDE... sounds like the name of the next User script or Chrome extension! –  jmort253 Oct 28 '12 at 20:30
    
Nice suggestion, for reference here is a question with lots of code. –  Shadow Wizard Oct 28 '12 at 21:24
    
I'm serious about a StackApp. User scripts can embed a button or mouseover event that would then expand the size of the code box. I don't think it would take that long to do if you wanted to give it a shot. ;) Chris, do you have a screenshot of what you have in mind? –  jmort253 Oct 28 '12 at 21:36
    
@jmort253: No, no screenshot. What I've seen here in the responses is mostly what I had in mind. I'm not familiar with the SO implementation, so I'm trying to keep to the requirement and keep away from any suggested implementation. –  Chris Gerken Oct 28 '12 at 23:03
    
@ShaWizDowArd, half of that "code" is unnecessary whitespace though... –  ben is uǝq backwards Oct 29 '12 at 15:06
    
@Ben still, it doesn't matter; a good example for what's being asked here. :-) –  Shadow Wizard Oct 29 '12 at 15:10
    
@ShaWizDowArd: Agreed. Another good example is almost any question on mapreduce problems where the PO has to show source for three or four classes. –  Chris Gerken Oct 29 '12 at 15:24
add comment

2 Answers

I wrote a greasemonkey/chrome user script about a year ago that does this. It's up on stackapps if you're interested.

From the link, it's features are:

  • Click the code region to have it expand to whatever size it needs
  • Removes vertical scroll altogether (expands to full height)
    • Intelligently expands horizontally
      • Maxes out at window width so as not to make even more scroll bars
      • If it still doesn't fit, it shrinks the font size
  • Click again to return it to normal
share|improve this answer
add comment

I really like this feature request. It focuses purely on making it easier for answerers to focus on looking at a problem and then creating great content. Here is a screenshot of one of the prettyprint windows expanded with some CSS manipulations:

Large code screen

Run this in the console to manipulate the window. This could either launch as a popup, which makes it easy to alt-tab back and forth, or just remain embedded in the page:

$('.default.prettyprint.prettyprinted').css("max-height","1200px");
$('.default.prettyprint.prettyprinted').css("width","950px");
$('div#sidebar').css("display","none");
$('.default.prettyprint.prettyprinted').css("border","thin solid black");

Of course, there is a downside to this: It may encourage more help vampires to post their entire project. We do know that Q&A tends to work best when it's represented in bite-sized, broken down components that focus on a single problem.

share|improve this answer
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .