deal with page down exception, fixes #2990

This commit is contained in:
Ben Fry
2015-04-01 16:19:31 -04:00
parent d1032eacc5
commit 3d5adcceef
2 changed files with 31 additions and 21 deletions

View File

@@ -864,21 +864,24 @@ public abstract class InputHandler extends KeyAdapter
int visibleLines = textArea.getVisibleLines();
int line = textArea.getCaretLine();
firstLine += visibleLines;
if (firstLine >= lineCount )
firstLine -= visibleLines;
else if(firstLine + visibleLines >= lineCount - 1)
firstLine = lineCount - visibleLines;
// Can't page down if there's nothing to visit
// https://github.com/processing/processing/issues/2990
if (lineCount > visibleLines) {
firstLine += visibleLines; // page down
if (firstLine + visibleLines >= lineCount - 1) {
// back up to the latest line we can go to
firstLine = lineCount - visibleLines;
}
textArea.setFirstLine(firstLine);
textArea.setFirstLine(firstLine);
int caret = textArea.getLineStartOffset(
Math.min(textArea.getLineCount() - 1,
line + visibleLines));
if(select)
textArea.select(textArea.getMarkPosition(),caret);
else
textArea.setCaretPosition(caret);
int caret = textArea.getLineStartOffset(Math.min(textArea.getLineCount() - 1, line + visibleLines));
if (select)
textArea.select(textArea.getMarkPosition(),caret);
else
textArea.setCaretPosition(caret);
}
}
}

View File

@@ -10,14 +10,10 @@ X https://github.com/processing/processing/issues/3014
X add more bulletproofing to the save process
X https://github.com/processing/processing/issues/2923
X serious text improvements (at least on retina)
_ finish adding 'examples' contribs
_ https://github.com/processing/processing/issues/2953
_ don't return here, allow contrib types to fail:
_ https://github.com/processing/processing/blob/master/app/src/processing/app/contrib/ContributionListing.java#L509
_ trying to add a second tab with the same name causes an error
_ Opening and closing preferences window prompts user to save unmodified sketch
_ https://github.com/processing/processing/issues/3074
X Menu mnemonics (alt-f, etc) getting typed into the editor
X https://github.com/processing/processing/issues/3057
X Opening and closing preferences window prompts user to save unmodified sketch
X https://github.com/processing/processing/issues/3074
_ implement line numbers in the editor
_ 5px between line number (right-aligned) and the right edge of the gutter
@@ -33,6 +29,8 @@ _ two new fonts have been added, other languages will need more
_ need a decent sans with with Unicode coverage
_ i.e. https://github.com/processing/processing/pull/3025
_ trying to add a second tab with the same name causes an error
jre download/install
X make sure the file downloads correctly before renaming
X https://github.com/processing/processing/issues/2960
@@ -86,6 +84,9 @@ X https://github.com/processing/processing/issues/2566
X make fatal errors terminate the pde
X https://github.com/processing/processing/issues/3068
X https://github.com/processing/processing/pull/3069
X Java 8 method replace() used, removed
X https://github.com/processing/processing/issues/3168
X https://github.com/processing/processing/pull/3169
manindra
X Fix for "Probably a ++ should go here" messages
@@ -176,6 +177,12 @@ _ crashed on startup w/ JavaScript mode as default b/c PdeKeyListener not found
_ because it's in the other ClassLoader, can no longer rely on it
_ remove JavaMode.errorLogsEnabled and JavaEditor.writeErrorsToFile()
3.0a7
_ finish adding 'examples' contribs
_ https://github.com/processing/processing/issues/2953
_ don't return here, allow contrib types to fail:
_ https://github.com/processing/processing/blob/master/app/src/processing/app/contrib/ContributionListing.java#L509
_ disable the debug toggle menu while running
_ otherwise could run in one mode, then try to stop in another
_ show debug window when running, hide when stopped