예제 #1
0
//creates the three Main big windows that make up the GUI
func createMainWindows(stdscr *gc.Window) (*gc.Window, *gc.Window, *gc.Window, *gc.Window, *gc.Window) {
	rows, cols := stdscr.MaxYX()
	height, width := rows, int(float64(cols)*.2)

	var contactsWin, messageWinBorder, inputBorderWin, inputWin *gc.Window
	var err error
	contactsWin, err = gc.NewWindow(height, width, 0, 0)
	if err != nil {
		log.Fatal("Failed to create Contact Window:", err)
	}
	err = contactsWin.Border('|', '|', '-', '-', '+', '+', '+', '+')
	if err != nil {
		log.Fatal("Failed to create Border of Contact Window:", err)
	}

	// messageWinBorder is just the border. msgWin is the actual input window
	// doing this simplifies handling text a fair amount.
	// also the derived function never errors. Which seems dangerous
	begin_x := width + 1
	height = int(float64(rows) * .8)
	width = int(float64(cols) * .8)
	messageWinBorder, err = gc.NewWindow(height, width, 0, begin_x)
	if err != nil {
		log.Fatal("Failed to create Message Border Window:", err)
	}
	err = messageWinBorder.Border('|', '|', '-', '-', '+', '+', '+', '+')
	if err != nil {
		log.Fatal("Failed to create Border of Message Window:", err)
	}
	msgWin, err := gc.NewWindow((height - 2), (width - 2), 1, (begin_x + 1))
	if err != nil {
		log.Fatal("Failed to create the message Window:", err)
	}

	begin_y := int(float64(rows)*.8) + 1
	height = int(float64(rows) * .2)
	inputBorderWin, err = gc.NewWindow(height, width, begin_y, begin_x)
	if err != nil {
		log.Fatal("Failed to create InputBorder Window:", err)
	}
	err = inputBorderWin.Border('|', '|', '-', '-', '+', '+', '+', '+')
	if err != nil {
		log.Fatal("Failed to create Border of the InputBorder Window:", err)
	}
	// inputBorderWin is just the border. InputWin is the actual input window
	// doing this simplifies handling text a fair amount.
	// also the derived function never errors. Which seems dangerous
	inputWin, err = gc.NewWindow((height - 2), (width - 2), (begin_y + 1), (begin_x + 1))
	if err != nil {
		log.Fatal("Failed to create the inputWin Window:", err)
	}

	inputWin.ScrollOk(true)
	inputWin.Keypad(true)
	msgWin.ScrollOk(true)

	return contactsWin, messageWinBorder, msgWin, inputBorderWin, inputWin
}