-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Table and Cursor refactoring. Minor bug fixes
- Loading branch information
1 parent
4330ca7
commit 1cfa221
Showing
8 changed files
with
115 additions
and
82 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package pacmanlogger | ||
|
||
import com.googlecode.lanterna.screen._ | ||
import com.googlecode.lanterna.graphics._ | ||
|
||
class FilterableTable(titles: List[String], totalTuples: List[List[String]], fullScreen: Boolean, screen: Screen, tg: TextGraphics) | ||
extends Table(titles, totalTuples, fullScreen, screen, tg) { | ||
|
||
var filter = (t: List[String]) => true | ||
tuples = totalTuples.filter(filter) | ||
|
||
override def updateValues = { | ||
super.updateValues | ||
tuples = totalTuples.filter(filter) | ||
} | ||
|
||
def setFilter(f: List[String] => Boolean) = { | ||
filter = f | ||
tuples = totalTuples.filter(filter) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package pacmanlogger | ||
|
||
import scala.collection.immutable.HashMap | ||
import com.googlecode.lanterna.screen._ | ||
import com.googlecode.lanterna.graphics._ | ||
|
||
abstract class OptionTable(title: String, var optionTuples: List[String], options: List[Boolean], subjectTable: FilterableTable, fullScreen: Boolean, screen: Screen, tg: TextGraphics) | ||
extends Table(List("", title), | ||
optionTuples.zip(options).map(t => | ||
t match { | ||
case (s, true) => List("[X]", s) | ||
case (s, false) => List("[ ]", s) | ||
}), fullScreen, screen, tg) { | ||
|
||
def switchOption(r: List[String]): Unit | ||
|
||
var settings: HashMap[String, Boolean] = { | ||
var m = new HashMap[String, Boolean] | ||
|
||
optionTuples.zip(options) foreach { | ||
case (action, option) => m = m.updated(action, option) | ||
} | ||
m | ||
} | ||
|
||
override def updateValues = { | ||
nRows = terminalSize.getRows - 2 | ||
tuples = { | ||
settings.toList map { (t: (String, Boolean)) => | ||
t match { | ||
case (s, true) => List("[X]", s) | ||
case (s, false) => List("[ ]", s) | ||
} | ||
} | ||
} | ||
rows = updateRows | ||
} | ||
} | ||
|
||
class FilterTable(title: String, tuples: List[String], options: List[Boolean], filteredTable: FilterableTable, fullScreen: Boolean, screen: Screen, tg: TextGraphics) | ||
extends OptionTable(title, tuples, options, filteredTable, fullScreen, screen, tg) { | ||
|
||
override def switchOption(r: List[String]) = { | ||
settings.toList foreach { | ||
case (s, true) if r(1) == s => | ||
val values: List[Boolean] = settings.toList.unzip._2 | ||
if (values.indexOf(true) != values.lastIndexOf(true)) | ||
settings = settings.updated(s, false) | ||
case (s, false) if r(1) == s => | ||
settings = settings.updated(s, true) | ||
case _ => () | ||
} | ||
filteredTable.filter = setFilterFunction | ||
} | ||
|
||
def setFilterFunction = { | ||
t: List[String] => | ||
settings.getOrElse(t(2), false) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters