pkg.re/essentialkaos/ek@v12.36.0+incompatible/terminal/window/example_test.go (about)

     1  package window
     2  
     3  // ////////////////////////////////////////////////////////////////////////////////// //
     4  //                                                                                    //
     5  //                         Copyright (c) 2021 ESSENTIAL KAOS                          //
     6  //      Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>     //
     7  //                                                                                    //
     8  // ////////////////////////////////////////////////////////////////////////////////// //
     9  
    10  import (
    11  	"fmt"
    12  )
    13  
    14  // ////////////////////////////////////////////////////////////////////////////////// //
    15  
    16  func ExampleGetSize() {
    17  	width, height := GetSize()
    18  
    19  	if width == -1 && height == -1 {
    20  		fmt.Println("Can't detect window size")
    21  		return
    22  	}
    23  
    24  	fmt.Printf("Window size: %d x %d\n", width, height)
    25  }
    26  
    27  func ExampleGetWidth() {
    28  	width := GetWidth()
    29  
    30  	if width == -1 {
    31  		fmt.Println("Can't detect window size")
    32  		return
    33  	}
    34  
    35  	fmt.Printf("Window width: %d\n", width)
    36  }
    37  
    38  func ExampleGetHeight() {
    39  	height := GetHeight()
    40  
    41  	if height == -1 {
    42  		fmt.Println("Can't detect window size")
    43  		return
    44  	}
    45  
    46  	fmt.Printf("Window height: %d\n", height)
    47  }