Browse Source

Call addLine with a \n delimited string.

Issue 1242


git-svn-id: http://svn.dmdirc.com/trunk@4078 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Shane Mc Cormack 16 years ago
parent
commit
e92ab141ce

+ 1
- 4
src/com/dmdirc/addons/logging/HistoryWindow.java View File

71
                 "plugin-Logging", "history.lines", 50000);
71
                 "plugin-Logging", "history.lines", 50000);
72
         final int frameBufferSize = IdentityManager.getGlobalConfig().getOptionInt(
72
         final int frameBufferSize = IdentityManager.getGlobalConfig().getOptionInt(
73
                 "ui", "frameBufferSize", 10000);
73
                 "ui", "frameBufferSize", 10000);
74
-        final Stack<String> lines = reader.getLines(Math.min(frameBufferSize, historyLineCount));
75
-        while (lines.size() > 0) {
76
-            window.addLine(lines.pop(), false);
77
-        }
74
+        window.addLine(reader.getLinesAsString(Math.min(frameBufferSize, historyLineCount)), false);
78
     }
75
     }
79
     
76
     
80
     /** {@inheritDoc} */
77
     /** {@inheritDoc} */

+ 24
- 1
src/com/dmdirc/addons/logging/ReverseFileReader.java View File

218
 	 * If the file is closed, an empty stack will be returned.
218
 	 * If the file is closed, an empty stack will be returned.
219
 	 *
219
 	 *
220
 	 * @param numLines Number of lines to try and get.
220
 	 * @param numLines Number of lines to try and get.
221
-     * @return The requested lines
221
+	 * @return The requested lines
222
 	 */
222
 	 */
223
 	public Stack<String> getLines(final int numLines) {
223
 	public Stack<String> getLines(final int numLines) {
224
 		final Stack<String> result = new Stack<String>();
224
 		final Stack<String> result = new Stack<String>();
231
 		}
231
 		}
232
 		return result;
232
 		return result;
233
 	}
233
 	}
234
+	
235
+	/**
236
+	 * Try and get x number of lines and return a \n delimited String.
237
+	 * If the file is closed, an empty string will be returned.
238
+	 *
239
+	 * @param numLines Number of lines to try and get.
240
+	 * @return The requested lines
241
+	 */
242
+	public String getLinesAsString(final int numLines) {
243
+		final StringBuilder result = new StringBuilder();
244
+		for (int i = 0; i < numLines; ++i) {
245
+			try {
246
+				result.insert(0, "\n");
247
+				result.insert(0, getNextLine());
248
+			} catch (IOException e) {
249
+				break;
250
+			}
251
+		}
252
+		if (result.charAt(0) == '\n') {
253
+			result.deleteCharAt(0);
254
+		}
255
+		return result.toString();
256
+	}
234
 }
257
 }

Loading…
Cancel
Save