mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 19:56:39 +00:00
fc3741365c
* Add Swagger spec test script * Fix Swagger spec errors not related to statuses with polls * Add API tests that post a status with a poll * Fix creating a status with a poll from form params * Fix Swagger spec errors related to statuses with polls (this is the last error) * Fix Swagger spec warnings not related to unused definitions * Suppress a duplicate list update params definition that was somehow causing wrong param names * Add Swagger test to CI - updates Drone config - vendorizes go-swagger - fixes a file extension issue that caused the test script to generate JSON instead of YAML with the vendorized version * Put `Sample: ` on its own line everywhere * Remove unused id param from emojiCategoriesGet * Add 5 more pairs of profile fields to account update API Swagger * Remove Swagger prefix from dummy fields It makes the generated code look weird * Manually annotate params for statusCreate operation * Fix all remaining Swagger spec warnings - Change some models into operation parameters - Ignore models that already correspond to manually documented operation parameters but can't be trivially changed (those with file fields) * Documented that creating a status with scheduled_at isn't implemented yet * sign drone.yml * Fix filter API Swagger errors * fixup! Fix filter API Swagger errors --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
86 lines
1.7 KiB
Go
86 lines
1.7 KiB
Go
// +build windows
|
|
|
|
package flags
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
type (
|
|
SHORT int16
|
|
WORD uint16
|
|
|
|
SMALL_RECT struct {
|
|
Left SHORT
|
|
Top SHORT
|
|
Right SHORT
|
|
Bottom SHORT
|
|
}
|
|
|
|
COORD struct {
|
|
X SHORT
|
|
Y SHORT
|
|
}
|
|
|
|
CONSOLE_SCREEN_BUFFER_INFO struct {
|
|
Size COORD
|
|
CursorPosition COORD
|
|
Attributes WORD
|
|
Window SMALL_RECT
|
|
MaximumWindowSize COORD
|
|
}
|
|
)
|
|
|
|
var kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
|
|
var getConsoleScreenBufferInfoProc = kernel32DLL.NewProc("GetConsoleScreenBufferInfo")
|
|
|
|
func getError(r1, r2 uintptr, lastErr error) error {
|
|
// If the function fails, the return value is zero.
|
|
if r1 == 0 {
|
|
if lastErr != nil {
|
|
return lastErr
|
|
}
|
|
return syscall.EINVAL
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func getStdHandle(stdhandle int) (uintptr, error) {
|
|
handle, err := syscall.GetStdHandle(stdhandle)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return uintptr(handle), nil
|
|
}
|
|
|
|
// GetConsoleScreenBufferInfo retrieves information about the specified console screen buffer.
|
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx
|
|
func GetConsoleScreenBufferInfo(handle uintptr) (*CONSOLE_SCREEN_BUFFER_INFO, error) {
|
|
var info CONSOLE_SCREEN_BUFFER_INFO
|
|
if err := getError(getConsoleScreenBufferInfoProc.Call(handle, uintptr(unsafe.Pointer(&info)), 0)); err != nil {
|
|
return nil, err
|
|
}
|
|
return &info, nil
|
|
}
|
|
|
|
func getTerminalColumns() int {
|
|
defaultWidth := 80
|
|
|
|
stdoutHandle, err := getStdHandle(syscall.STD_OUTPUT_HANDLE)
|
|
if err != nil {
|
|
return defaultWidth
|
|
}
|
|
|
|
info, err := GetConsoleScreenBufferInfo(stdoutHandle)
|
|
if err != nil {
|
|
return defaultWidth
|
|
}
|
|
|
|
if info.MaximumWindowSize.X > 0 {
|
|
return int(info.MaximumWindowSize.X)
|
|
}
|
|
|
|
return defaultWidth
|
|
}
|