~kris/9p

disco

8ec394a4df5e5bb220bb2e1379781da5c6e707cc — Sean Hinchee 9 years ago e42a94b
Adding plan9 raw mode
3 files changed, 33 insertions(+), 13 deletions(-)

M config.go
M helper.go
M main.go
M config.go => config.go +33 -2
@@ 8,7 8,7 @@ import (
	"os"
	"os/user"

	"golang.org/x/crypto/ssh/terminal"
//	"golang.org/x/crypto/ssh/terminal"
)

//Configuration is a struct that contains all configuration fields


@@ 64,7 64,38 @@ func CreateConfig() {

	EmptyStruct.Username = scan.Text()
	fmt.Println("Input your password")
	password, err := terminal.ReadPassword(0)
	//password, err := terminal.ReadPassword(0)
	
	plan9 := true
	/* Plan 9 raw mode for rio */
	consctl, err := os.Open("/dev/consctl")
	if err != nil {
		/* not on Plan 9 */
		plan9 = false
	}
	
	password := "";
	
	if plan9 {
		rawon := make([]byte, 5)
		rawon = []byte("rawon")
		_, err = consctl.Write(rawon)
		if err != nil {
			fmt.Println("Failed to set rawon")
		} else {
			cons, err := os.Open("/dev/cons")
			scan := bufio.NewScanner(cons)
			scan.Scan()
			password = scan.Text()
			rawoff := make([]byte, 6)
			rawoff = []byte("rawoff")
			_, err = consctl.Write(rawoff)
			if err != nil {
				fmt.Println("Failed to set rawoff")
			}
		}
	}
	
	EmptyStruct.Password = string(password)
	EmptyStruct.Messages = 10
	EmptyStruct.MessageDefault = true

M helper.go => helper.go +0 -8
@@ 2,7 2,6 @@ package main

import (
	"log"
	"os"
	"os/exec"
	"strings"
	"time"


@@ 22,13 21,6 @@ func Msg(MsgType, format string, a ...interface{}) {
	fmt.Printf(format, a...)
}

//Clear clears the terminal => This barely works, please fix → Nope
func Clear() {
	c := exec.Command("clear")
	c.Stdout = os.Stdout
	c.Run()
}

//Header simply prints a header containing state/session information
func Header() {
	Msg(InfoMsg, "Welcome, %s!\n\n", State.Session.User.Username)

M main.go => main.go +0 -3
@@ 37,7 37,6 @@ func main() {
	//Initialize Config
	GetConfig()
	CheckState()
	Clear()
	Msg(HeaderMsg, "disco version: %s\n\n", Version)

	//NewSession


@@ 97,7 96,6 @@ func InitWindow() {

//ShowContent shows defaulth Channel content
func ShowContent() {
	Clear()
	Header()
	if Config.MessageDefault {
		State.RetrieveMessages(Config.Messages)


@@ 107,7 105,6 @@ func ShowContent() {

//ShowEmptyContent shows an empty channel
func ShowEmptyContent() {
	Clear()
	Header()
}