summary refs log tree commit diff stats
path: root/widgets/account.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/account.go')
-rw-r--r--widgets/account.go35
1 files changed, 29 insertions, 6 deletions
diff --git a/widgets/account.go b/widgets/account.go
index c5545ef..3085d27 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -21,6 +21,7 @@ type AccountView struct {
 	interactive  ui.Interactive
 	onInvalidate func(d ui.Drawable)
 	runCmd       func(cmd string) error
+	msgStores    map[string]*MessageStore
 	statusline   *StatusLine
 	statusbar    *ui.Stack
 	worker       *types.Worker
@@ -64,9 +65,10 @@ func NewAccountView(conf *config.AccountConfig,
 		dirlist:    dirlist,
 		grid:       grid,
 		logger:     logger,
+		msgStores:  make(map[string]*MessageStore),
 		runCmd:     runCmd,
-		statusline: statusline,
 		statusbar:  statusbar,
+		statusline: statusline,
 		worker:     worker,
 	}
 
@@ -157,10 +159,6 @@ func (acct *AccountView) connected(msg types.WorkerMessage) {
 			Message:  types.RespondTo(msg),
 			Approved: true,
 		}, acct.connected)
-	case *types.Error:
-		acct.logger.Printf("%v", msg.Error)
-		acct.statusline.Set(fmt.Sprintf("%v", msg.Error)).
-			Color(tcell.ColorRed, tcell.ColorDefault)
 	}
 }
 
@@ -169,5 +167,30 @@ func (acct *AccountView) Directories() *DirectoryList {
 }
 
 func (acct *AccountView) onMessage(msg types.WorkerMessage) {
-	// TODO
+	switch msg := msg.(type) {
+	case *types.Done:
+		switch msg.InResponseTo().(type) {
+		case *types.OpenDirectory:
+			acct.worker.PostAction(&types.FetchDirectoryContents{},
+				func(msg types.WorkerMessage) {
+					// TODO: Do we care
+				})
+		}
+	case *types.DirectoryInfo:
+		if store, ok := acct.msgStores[msg.Name]; ok {
+			store.Update(msg)
+		} else {
+			acct.msgStores[msg.Name] = NewMessageStore(msg)
+		}
+	case *types.DirectoryContents:
+		store := acct.msgStores[acct.dirlist.selected]
+		store.Update(msg)
+	case *types.MessageInfo:
+		store := acct.msgStores[acct.dirlist.selected]
+		store.Update(msg)
+	case *types.Error:
+		acct.logger.Printf("%v", msg.Error)
+		acct.statusline.Set(fmt.Sprintf("%v", msg.Error)).
+			Color(tcell.ColorRed, tcell.ColorDefault)
+	}
 }
; 2016-09-15 13:46:13 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2016-09-15 14:04:22 -0700 3365 - create strings out of arbitrary types' href='/akkartik/mu/commit/059to_text.mu?h=hlt&id=b75d9d456cb36ad41ab735586473adbbf3444643'>b75d9d45 ^
08f4628e ^

a0331a9b ^
b75d9d45 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48







                                                                              
                                    





                                                                
                                              





                                                         
                           



                                                               
                                 
                                

                                    

                                                 
                              






                                     

                          
                          



                            
# A couple of variants of `to-text` that we'll use implicitly in stashes (see
# later layers).
#
# Mu code might specialize them to be smarter, but I don't anticipate any need
# beyond specializing `to-text` itself.

# 'shorter' variant of to-text, when you want to enable some sort of trimming
# define it to be identical to 'to-text' by default
def to-text-line x:_elem -> y:text [
  local-scope
  load-ingredients
  y <- to-text x
]

# variant for arrays (since we can't pass them around otherwise)
def array-to-text-line x:&:@:_elem -> y:text [
  local-scope
  load-ingredients
  y <- to-text *x
]

scenario to-text-line-early-warning-for-static-dispatch [
  x:text <- to-text-line 34
  # just ensure there were no errors
]

scenario array-to-text-line-early-warning-for-static-dispatch [
  n:&:@:num <- new number:type, 3
  x:text <- array-to-text-line n
  # just ensure there were no errors
]

# finally, a specialization for single characters
def to-text c:char -> y:text [
  local-scope
  load-ingredients
  y <- new character:type, 1/capacity
  *y <- put-index *y, 0, c
]

scenario character-to-text [
  1:char <- copy 111/o
  2:text <- to-text 1:char
  3:@:char <- copy *2:text
  memory-should-contain [
    3:array:character <- [o]
  ]
]