// makes the menu inside the contacts window func makeContactsMenu(contacts []ts.Contact, contactsWin *gc.Window) ([]*gc.MenuItem, *gc.Menu, *gc.Window) { menu_items := make([]*gc.MenuItem, len(contacts)) var err error for i, val := range contacts { menu_items[i], err = gc.NewItem((val.Name), "") if err != nil { log.Fatal("Error making item for contact menu... ", err) } } contactMenu, err := gc.NewMenu(menu_items) if err != nil { log.Fatal("Error creating contact menu from menu_items... ", err) } contactsWinSizeY, contactsWinSizeX := contactsWin.MaxYX() contactsWin.Keypad(true) contactsMenuWin := contactsWin.Derived((contactsWinSizeY - 5), (contactsWinSizeX - 2), 3, 1) contactMenu.SetWindow(contactsMenuWin) contactMenu.Format(len(contacts), 1) contactMenu.Mark(" * ") title := "Contacts" contactsWin.MovePrint(1, (contactsWinSizeX/2)-(len(title)/2), title) contactsWin.HLine(2, 1, '-', contactsWinSizeX-2) contactsMenuWin.Keypad(true) contactsMenuWin.ScrollOk(true) return menu_items, contactMenu, contactsMenuWin }
func PrintHiglighted(window *gc.Window, y int, x int, index int, selected int, text string, isActive bool) { if index == selected && isActive { window.AttrOn(gc.A_STANDOUT) } window.MovePrint(y, x, text) if index == selected && isActive { window.AttrOff(gc.A_STANDOUT) } }
func printmenu(w *gc.Window, menu []string, active int) { y, x := 2, 2 w.Box(0, 0) for i, s := range menu { if i == active { w.AttrOn(gc.A_REVERSE) w.MovePrint(y+i, x, s) w.AttrOff(gc.A_REVERSE) } else { w.MovePrint(y+i, x, s) } } w.Refresh() }
// Prints messages to the message window func printToMsgWindow(msg string, msgWin *gc.Window, amSending bool) { lines := int(len(msg)/(msgWinSize_x-1)) + 1 if amSending == true { msgWin.Scroll(lines) msgWin.ColorOn(2) msgWin.MovePrint((msgWinSize_y - lines), 0, msg) } else { if strings.ContainsAny(msg, "\n") { printByLineBreakdown := strings.Split(msg, "\n") for i, val := range printByLineBreakdown { if i != 0 { msgWin.Scroll(1) } lines2 := int(len(val)/(msgWinSize_x-1)) + 1 if lines2 > 1 { msgWin.Scroll(lines2) msgWin.ColorOn(1) msgWin.MovePrint((msgWinSize_y - lines2), int(msgWinSize_x*3/4), val) } else { msgWin.Scroll(lines2) msgWin.ColorOn(1) space_buf := (msgWinSize_x) - len(val) msgWin.MovePrint((msgWinSize_y - lines), space_buf, val) msgWin.Scroll(-1) } } } else { if lines > 1 { msgWin.Scroll(lines) msgWin.ColorOn(1) msgWin.MovePrint((msgWinSize_y - lines), int(msgWinSize_x*3/4), msg) } else { msgWin.Scroll(lines) msgWin.ColorOn(1) space_buf := (msgWinSize_x) - len(msg) msgWin.MovePrint((msgWinSize_y - lines), space_buf, msg) msgWin.Scroll(-1) } } } msgWin.Refresh() globalInputWin.Refresh() }
// Function to call to update the information in the information Window. func displayInfo(win *gc.Window, active, activeA int, userItems []*gc.MenuItem, userArticles map[string][]articleType) { win.Clear() win.MovePrint(1, 0, "Auteur : ", userItems[active].Name()) win.MovePrint(2, 0, "Date : ", userArticles[userItems[active].Name()][activeA].date) win.MovePrint(4, 0, userArticles[userItems[active].Name()][activeA].url) win.Refresh() }