Skip to content

Commit 287e3b0

Browse files
committed
Half implemented scrolling
1 parent 3ef5e3a commit 287e3b0

File tree

5 files changed

+40
-35
lines changed

5 files changed

+40
-35
lines changed

flshell

4.04 KB
Binary file not shown.

interfacecontroller.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,45 @@
44

55
package main
66

7+
import "strings"
8+
79
// messageRetrieve ... Pass the users selection as an inode for fls or command+inode for carving and a slice of the current
810
// directory to retrieve a single element of the slice.
9-
func messageRetrieve(selection string, input []string) string {
11+
func messageRetrieve(selection string, input []string) (results string, log string) {
1012

1113
//Pull the inode and name from the selection.
1214
// TODO Test this on selection without a slice to determine how robust the regex is.
1315
selectionInode := inodeMatcher(selection)
1416
selectionName := nameMatcher(selection)
17+
selectedType := dirMatcher(selection)
1518

1619
// Does not matter that this is not robust logic, input will be locked down by line selection in tcell version.
1720
// References to global executionArgs and the unallocatedRecover command line parameter
1821
// Return a success message if executeCarvers completes successfully, else return a failure message to the user.
19-
if selection[0] == 't' {
22+
if strings.Contains(selectedType, "d") {
2023
if executeCarvers("tsk_recover", argsUpdaterRecover(executionArgsRecover, selectionInode, *unallocatedRecover), selectionName) {
21-
return "Successfully carved " + selectionName
24+
return "", "Successfully carved " + selectionName
2225
}
23-
return "Failed to carve " + selectionName
26+
return "", "Failed to carve " + selectionName
2427
}
2528

26-
if selection[0] == 'i' {
29+
if strings.Contains(selectedType, "r") {
2730
if executeCarvers("icat", argsUpdater(executionArgs, selectionInode), selectionName) {
28-
return "Successfully carved " + selectionName
31+
return "", "Successfully carved " + selectionName
2932
}
30-
return "Failed to carve " + selectionName
31-
} else {
32-
// If there's nothing in the selection string providing direction to carve,
33-
// then iterate through input and return a line that has an inode matching to the
34-
// selectionInode.
35-
for _, inputLine := range input {
36-
if selectionInode == inodeMatcher(inputLine) {
37-
return inputLine
33+
return "", "Failed to carve " + selectionName
34+
}
35+
// If there's nothing in the selection string providing direction to carve,
36+
// then iterate through input and return a line that has an inode matching to the
37+
// selectionInode.
38+
for _, inputLine := range input {
39+
if selectionInode == inodeMatcher(inputLine) {
40+
if !executeFLS(executionArgs) {
41+
return inputLine, ""
3842
}
43+
return "", "FLS failed to execute on directory: " + selectionName
3944
}
4045
}
41-
return "Unable to find a line in the input that matches the input string."
46+
47+
return "", "Unable to find a line in the FLS input slice that matches the selected input string."
4248
}

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func main() {
3131

3232
// setupMain ... Initialise and setup variables before entering the main loop of program execution.
3333
// Assign command line parameters to variables and conduct an initial run of FLS in the root directory.
34+
// TODO: integrate initial FLS execution with interfacecontroller.go
3435
func setupMain() {
3536
flag.Parse()
3637
executionArgs = []string{"-o", *diskoffset, *imagepath, "5"}

view.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ func drawBody(s tcell.Screen, content []string, selectedline int) {
7474
}
7575
}
7676

77-
// Line ... Represents a line that gets drawn to the screen
78-
type Line struct {
79-
num int
80-
text string
81-
}
82-
8377
// colourRow ... Set a row on the screen with the specified style, ideally with a specific background colour.
8478
func colourRow(s tcell.Screen, style tcell.Style, row int) {
8579
for x := 0; x < windowWidth; x++ {

viewcontroller.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
)
88

99
// globally defined selected line starts at 1 to account for header width.
10+
// sl is the line within the view, it does not represent the line in the currentSplit
1011
var sl = 1
1112

1213
// loop ... main execution loop. Figure out wtf is happening here.
@@ -22,16 +23,17 @@ func loop(s tcell.Screen) {
2223
close(quit)
2324
return
2425
case tcell.KeyDown:
25-
moveSelectedLine(1, sl, 1, 1)
26+
moveSelectedLine(1, sl, len(currentSplit), 1, 1)
2627

2728
case tcell.KeyUp:
28-
moveSelectedLine(-1, sl, 1, 1)
29+
moveSelectedLine(-1, sl, len(currentSplit), 1, 1)
2930

3031
case tcell.KeyLeft:
3132

32-
s.Sync()
3333
case tcell.KeyRight:
34-
s.Sync()
34+
//determine index into selectedSlice that selectedline is pointed at.
35+
//pass selectedline to windowstring to messageretrieve
36+
//messageRetrieve()
3537
}
3638
case *tcell.EventResize:
3739
s.Sync()
@@ -56,7 +58,7 @@ loop:
5658
// moveSelectedLine ... Return the currently selected line with deviation specified by amount value.
5759
// Amount should only ever be 1 or -1. The logic in moveSelectedLine is not robust enough
5860
// to safely handle other values.
59-
func moveSelectedLine(amount int, selectedline int, headerheight int, footerheight int) {
61+
func moveSelectedLine(amount int, selectedline int, lenlines int, headerheight int, footerheight int) {
6062
// if amount is a negative value and the currently selected line is the top (ie, headerwidth), keep it at the
6163
// at the index that's the same thickness as the header.
6264
if (amount < 0) && (selectedline == headerheight) {
@@ -65,6 +67,8 @@ func moveSelectedLine(amount int, selectedline int, headerheight int, footerheig
6567
// then return the max value.
6668
} else if (amount > 0) && (selectedline == windowHeight-footerheight-1) {
6769
sl = windowHeight - footerheight - 1
70+
} else if (amount > 0) && (selectedline == lenlines-1) {
71+
sl = lenlines - 1
6872
} else {
6973
sl = selectedline + amount
7074
}
@@ -73,19 +77,19 @@ func moveSelectedLine(amount int, selectedline int, headerheight int, footerheig
7377

7478
// windowString ... takes a chunk of text delimited by newlines and returns a specified portion of it
7579
// that fits within the current size of the terminal window. A number of lines to offset
76-
// into the original message must be provided by the selected integer.
77-
// windowheight will usually be an integer that starts at 1 whereas selected is likely
80+
// into the original message must be provided by the offset integer.
81+
// windowheight will usually be an integer that starts at 1 whereas offset is likely
7882
// starting from 0. When passing variables to this function, it is recommended to increment
79-
// selected by 1.
83+
// offset by 1.
8084
// The function does not return a reduced portion of the input message if it has less lines
8185
// than windowheight.
82-
/*func windowString(lines []string, selectedline int, headerheight int, footerheight int) []string {
83-
if windowHeight-headerheight-footerheight >= len(lines) {
86+
func currentWindow(lines []string, offset int, headerheight int, footerheight int) []string {
87+
limit := windowHeight - headerheight - footerheight
88+
if limit >= len(lines) {
8489
return lines
8590
}
86-
if selected > windowheight {
87-
return strings.Join(lines[selected-windowheight:selected], "\n")
91+
if offset > limit {
92+
return lines[offset-limit : offset]
8893
}
89-
return strings.Join(lines[0:windowheight], "\n")
94+
return lines[0:limit]
9095
}
91-
*/

0 commit comments

Comments
 (0)