Skip to content

Commit

Permalink
Merge branch 'release/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocastoldi committed Apr 4, 2018

Unverified

This user has not yet uploaded their public signing key.
2 parents 63f892a + 4863c73 commit 4330ca7
Showing 11 changed files with 362 additions and 332 deletions.
Binary file modified .cache-main
Binary file not shown.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,29 @@
![Lanterna screenshot](resources/PacmanLogger.png)
An application with terminal GUI inspired by htop that makes Arch pacman's logs easier to read. Written in Scala

## Dependencies
## Installation
### Dependencies
Mandatory:
- Java (jre)

### Package Manager
#### Arch Linux
Available via AUR here: https://aur.archlinux.org/packages/pacmanlogger-git/

### Manual (sbt)
Compiling:
```bash
git clone https://github.com/carlocastoldi/PacmanLogger.git
cd PacmanLogger
sbt assembly
cp target/scala-2.12/PacmanLogger-assembly-<version>.jar ./pacmanlogger.jar
```
Running:
```bash
java -jar pacmanlogger.jar
```

## Developing tools
- Scala (http://www.scala-lang.org/)
- lanterna-3.0.0 (https://github.com/mabe02/lanterna)
- scala-parser-combinators (https://github.com/scala/scala-parser-combinators)
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "PacmanLogger"

version := "0.1.0"
version := "0.1.2"

scalaVersion := "2.12.4"

23 changes: 12 additions & 11 deletions src/main/scala/pacmanlogger/AbstractTable.scala
Original file line number Diff line number Diff line change
@@ -6,15 +6,16 @@ import com.googlecode.lanterna.graphics._
import com.googlecode.lanterna.terminal._

trait AbstractTable {
def getRows: List[List[String]]
def updateValues: Unit
def isLastRow: Boolean
def scrollRows(n: Int): Unit
def scrollStart: Unit
def scrollEnd: Unit
def getScreen: Screen
def getFirstRow: Int
def getTextGraphics: TextGraphics
def draw(terminalSize: TerminalSize, offset: Integer)
def drawRow(titles: List[String], column: Int, row: Int)
def getRows: List[List[String]]
def getAllRows: List[List[String]]
def updateValues: Unit
def isLastRow: Boolean
def scrollRows(n: Int): Unit
def scrollStart: Unit
def scrollEnd: Unit
def getScreen: Screen
def getFirstRow: Int
def getTextGraphics: TextGraphics
def draw(terminalSize: TerminalSize, offset: Integer)
def drawRow(titles: List[String], column: Int, row: Int)
}
132 changes: 66 additions & 66 deletions src/main/scala/pacmanlogger/Cursor.scala
Original file line number Diff line number Diff line change
@@ -4,87 +4,87 @@ import com.googlecode.lanterna._
import com.googlecode.lanterna.graphics._

trait Cursor extends AbstractTable {
var cursorAbsolutePos = 0
var cursorAbsolutePos = 0
var cursorRelativePos = 0
val screen = getScreen
val tg = getTextGraphics
var rows_ = getRows
var nRows_ = rows_.length

abstract override def draw(terminalSize: TerminalSize, offset: Integer) {
super.draw(terminalSize, offset)
if(terminalSize.getRows-3 < cursorRelativePos)
cursorRelativePos = terminalSize.getRows-3
drawCursor(offset)
}

def moveCursor(n: Int, tg: TextGraphics, offset: Int, terminalSize: TerminalSize) {
rows_ = getRows
nRows_ = rows_.length
(cursorRelativePos+n) match {
case i if i >= 0 && i < nRows_ =>
delCursor(offset)
cursorRelativePos += n
drawCursor(offset)
case i if !isLastRow =>
var firstRow_ = getFirstRow
scrollRows(n)
super.draw(terminalSize, offset)
if (terminalSize.getRows - 3 < cursorRelativePos)
cursorRelativePos = terminalSize.getRows - 3
drawCursor(offset)
}

delCursor(offset)
cursorRelativePos += n - (getFirstRow - firstRow_)
def moveCursor(n: Int, tg: TextGraphics, offset: Int, terminalSize: TerminalSize) {
rows_ = getRows
nRows_ = rows_.length
(cursorRelativePos + n) match {
case i if i >= 0 && i < nRows_ =>
delCursor(offset)
cursorRelativePos += n
drawCursor(offset)
case i if !isLastRow =>
var firstRow_ = getFirstRow
scrollRows(n)

if (cursorRelativePos < 0) {
cursorRelativePos = 0
}
delCursor(offset)
cursorRelativePos += n - (getFirstRow - firstRow_)

if (cursorRelativePos > nRows_ - 1) {
cursorRelativePos = nRows_ - 1
}
if (cursorRelativePos < 0) {
cursorRelativePos = 0
}

drawCursor(offset)
draw(terminalSize, offset)
case _ => ()
}
}
if (cursorRelativePos > nRows_ - 1) {
cursorRelativePos = nRows_ - 1
}

def moveCursorStart(tg: TextGraphics, offset: Int, terminalSize: TerminalSize) {
delCursor(offset)
cursorRelativePos = 0
drawCursor(offset)
scrollStart
draw(terminalSize, offset)
}
drawCursor(offset)
draw(terminalSize, offset)
case _ => ()
}
}

def moveCursorEnd(tg: TextGraphics, offset: Int, terminalSize: TerminalSize) {
rows_ = getRows
nRows_ = rows_.length
def moveCursorStart(tg: TextGraphics, offset: Int, terminalSize: TerminalSize) {
delCursor(offset)
cursorRelativePos = 0
drawCursor(offset)
scrollStart
draw(terminalSize, offset)
}

delCursor(offset)
cursorRelativePos = nRows_ - 1
drawCursor(offset)
scrollEnd
draw(terminalSize, offset)
}

def delCursor(offset: Int) {
updateValues
rows_ = getRows
nRows_ = rows_.length
tg.setForegroundColor(TextColor.ANSI.CYAN)
tg.setBackgroundColor(TextColor.ANSI.DEFAULT)
drawRow(rows_(cursorRelativePos), offset, cursorRelativePos+1)
}

def drawCursor(offset: Int) {
updateValues
rows_ = getRows
nRows_ = rows_.length
tg.setForegroundColor(TextColor.ANSI.BLACK)
tg.setBackgroundColor(TextColor.ANSI.CYAN)
drawRow(rows_(cursorRelativePos), offset, cursorRelativePos+1)
}
def moveCursorEnd(tg: TextGraphics, offset: Int, terminalSize: TerminalSize) {
rows_ = getRows
nRows_ = rows_.length

delCursor(offset)
cursorRelativePos = nRows_ - 1
drawCursor(offset)
scrollEnd
draw(terminalSize, offset)
}

def delCursor(offset: Int) {
updateValues
rows_ = getRows
nRows_ = rows_.length
tg.setForegroundColor(TextColor.ANSI.CYAN)
tg.setBackgroundColor(TextColor.ANSI.DEFAULT)
drawRow(rows_(cursorRelativePos), offset, cursorRelativePos + 1)
}

def drawCursor(offset: Int) {
updateValues
rows_ = getRows
nRows_ = rows_.length
tg.setForegroundColor(TextColor.ANSI.BLACK)
tg.setBackgroundColor(TextColor.ANSI.CYAN)
drawRow(rows_(cursorRelativePos), offset, cursorRelativePos + 1)
}
}

trait OptionCursor extends OptionTable with Cursor {
def getSelectedRow = rows_(cursorRelativePos)
def getSelectedRow = rows_(cursorRelativePos)
}
Loading

0 comments on commit 4330ca7

Please sign in to comment.