Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

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

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, its 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

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

Ok, this question has been around a while! But it is exactly what I was going to ask about. And I have a possible solution. When you are on a web site which includes photos, you can often click the photo and it opens up in a "modal" fashion to take up the entire window, and you see the photo in as large an area as the window allows. Often there will be an X in the upper right corner, and perhaps some zoom features. Pressing the Esc key often can close it. Left and Right arrows can go to the next or previous photo.

Why not do this with code blocks? Add an "expand" button next to (or above/below) the code sample. When clicked, it expands to take the entire window (full width, full height please!). Perhaps with "zoom" buttons so those younger folks can click the "zoom out" to see more at once, and the older folks can click "zoom in" if necessary when they eyes stop working like they used to. And of course you could easily scroll both directions, perhaps there would even be a "copy to clipboard" button to copy the entire sample. And for answers with multiple code blocks, the left and right arrows could bring up the previous or next code block from the question or answer.

share|improve this answer

You must log in to answer this question.

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