package com.vaguehope.mikuru;

import android.widget.ScrollView;
import android.widget.TextView;

public class ConsoleAppender {
//	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	private final TextView tv;
	private final ScrollView sv;
	
//	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	public ConsoleAppender (TextView tv, ScrollView sv) {
		this.tv = tv;
		this.sv = sv;
	}
	
//	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	public void append (String... msgs) {
		for (String msg : msgs) {
			this.tv.append(msg);
		}
		this.sv.smoothScrollTo(0, this.tv.getHeight());
	}
	
	public void clear () {
		this.tv.setText("");
	}
	
//	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}

@@ -24,16 +24,42 @@
 ikuru;%0A%0A
+import android.view.View;%0A
 import a
@@ -256,29 +256,31 @@
 View tv;%0A%09pr
-ivate
+otected
  final Scrol
@@ -613,13 +613,8 @@
 gs) 
-%7B%0A%09%09%09
 this
@@ -634,12 +634,8 @@
 g);%0A
-%09%09%7D%0A
 %09%09th
@@ -644,50 +644,187 @@
 .sv.
-smoothScrollTo(0, 
+post(this.scrollDown);%0A%09%7D%0A%09%0A%09private final Runnable scrollDown = new Runnable() %7B%0A%09%09@Override%0A%09%09public void run() %7B%0A%09%09%09ConsoleAppender.
 this.
-tv.getHeight());%0A%09%7D
+sv.fullScroll(View.FOCUS_DOWN);%0A%09%09%7D%0A%09%7D;
 %0A%09%0A%09

Fix console appended to work correctly.